| Coming from ruby, and trying to familiar myself with this lispy arc. I wanted a function that could strip multiple characters from a string, and so far I've found two more or less obvious way, although normally I'd use iteration above recursion in ruby. Is there a style/computer mechanical/any reason why one would be preferred to be used above the other? And are there other interesting versions possible? Both of these take (strip list string) and return the stripped string. (def strip (lst str) (if (no lst) str (strip (cdr lst) (rem ((car lst) 0) str))))
(def strip2 (lst str)
(each x '("a" "b" "e") (= str (rem (x 0) str)))
str)
|