3 ms·
Your snippet would be condensed into 1 indentation block with pattern matching. In scheme it'd be even more explicit that we're deconstructing command, therefor
by fatcow 6y ago
Your snippet would be condensed into 1 indentation block with pattern matching. In scheme it'd be even more explicit that we're deconstructing command, therefore much much easier to follow logic. No need to worry about cmd, args, etc.
(match command
(("quit") (display "Goodbye!"))
(("look") (describe current-room))
(("get" obj) (character-get obj current-room))
(("go" dir) (set! current-room (room-neighbour dir)))
(_ (display "Invalid command")))