This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| let random_object = System.Random() | |
| let filelines filename = System.IO.File.ReadAllLines(__SOURCE_DIRECTORY__ + "/" + filename) | |
| let get_random_line file = random_object.Next(0, Seq.length(file)) | |
| let get_random_word word_file = Seq.nth (get_random_line word_file) (word_file) | |
| type words = | |
| | Verb | |
| | Noun | |
| | Adjective |
| zeroes 0 = [] | |
| zeroes n = [0] ++ (zeroes (n-1)) | |
| foo x y z= zipWith (+) (zipWith (+) x y) z | |
| grid_neighbours l = | |
| let top = map inc_neighbours ( [(zeroes (length (head l)))] ++ (take (length l) l) ) | |
| bottom = map inc_neighbours ((drop 1 l) ++ [(zeroes (length (head l)))]) | |
| current = map neighbours l | |
| in zipWith3 foo top bottom current |
| ;; mattyw's solution to Reverse a Sequence | |
| ;; https://4clojure.com/problem/23 | |
| (defn reverse-func [seq] | |
| (reduce (fn [a b] (cons b a)) '() seq)) | |
| (println (= (reverse-func [1 2 3 4 5]) [5 4 3 2 1])) |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer