Mercurial > rlm
comparison src/rlm/dylan-reverse-seq.clj @ 0:78a630e650d2
initial import
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 18 Oct 2011 00:57:08 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:78a630e650d2 |
---|---|
1 (ns coderloop.reverse-sequence) | |
2 (use 'clojure.contrib.str-utils) | |
3 ;;(use 'rlm.shell-inspect) | |
4 | |
5 (defn extension[f ip op] (fn[x](if (= x ip) op (f x)))) | |
6 | |
7 (let[ | |
8 ;;*command-line-args* (list "/home/ocsenave/testfile.txt") | |
9 pairs (if (nil? *command-line-args*) '() (map #(re-split #" " %) (re-split #"\r\n" (slurp(first *command-line-args*))))) | |
10 predecessor (reduce #(extension %1 (second %2)(first %2)) (fn[x]nil) pairs) | |
11 terminus (first(remove(set(map first pairs))(map second pairs))) | |
12 ] | |
13 (defn lineage[x](if(nil? x)nil (cons x(lineage (predecessor x))))) | |
14 (print (str-join "\n" (lineage terminus))) | |
15 ) | |
16 | |
17 | |
18 ;;(if (command-line?) | |
19 ;; (do-something-to *command-line-args*)) | |
20 |