Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| ; P12 Decode a run-length encoded list. | |
| ; Mapping | |
| (defn f1 [l] | |
| (defn f [x] (if (vector? x) (repeat (first x) (second x)) x)) | |
| (flatten (map f l))) | |
| ; Recursion | |
| (defn f2 [l] | |
| (if (seq l) | |
| (let [h (first l) t (rest l)] | |
| (if (vector? h) | |
| (concat (repeat (first h) (second h)) (f2 t)) | |
| (cons h (f2 t)))) | |
| '())) |