4 ms·
Not really. I find I very rarely write functions with explicit loops, because there is usually a higher-level function that encompasses what I want to do. For
by weavejester 16y ago
Not really. I find I very rarely write functions with explicit loops, because there is usually a higher-level function that encompasses what I want to do.
For example, in Clojure I'd write the flatten function as:
(defn flatten [x]
(remove sequential? (tree-seq sequential? seq x)))
Other lisps probably have similar functions.
- jimbokun 16y agoDidn't know about tree-seq. Cool. I suspect I will find a lot of uses for it, now that I know about it.