madlisp/mad/util.mad

14 lines
340 B
Plaintext

;;
;; Generic utility functions.
;;
;; Split string by whitespace, removing empty strings.
(defn split-ws (s) (re-split "/[\\s]+/" s))
;; Split string by whitespace into first and rest.
;; Useful for parsing a string for command name and arguments.
(defn str-first-rest (s)
(let (words (split-ws s))
[(first words) (tail words)]))