Last active
August 29, 2015 13:56
-
-
Save cronin101/9327891 to your computer and use it in GitHub Desktop.
I have no idea what I am doing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn my_even? [n] | |
| (= 0 (rem n 2))) | |
| (defn my_filter [test_fn input_list] | |
| (defn recstep [remaining_input acc] | |
| (if (= 0 (count remaining_input)) | |
| acc | |
| (let [ next_input (drop 1 remaining_input) | |
| this_ele (first remaining_input) | |
| next_acc (if (test_fn this_ele) | |
| (concat acc [this_ele]) | |
| acc)] | |
| (recstep next_input next_acc)))) | |
| (recstep input_list (list))) | |
| (prn | |
| (my_filter my_even? (take 10 (range)))) | |
| ; > (0 2 4 6 8) | |
| ; => nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment