diff 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
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/rlm/dylan-reverse-seq.clj	Tue Oct 18 00:57:08 2011 -0700
     1.3 @@ -0,0 +1,20 @@
     1.4 +(ns coderloop.reverse-sequence)
     1.5 +(use 'clojure.contrib.str-utils)
     1.6 +;;(use 'rlm.shell-inspect)
     1.7 +
     1.8 +(defn extension[f ip op] (fn[x](if (= x ip) op (f x))))
     1.9 +
    1.10 +(let[
    1.11 +     ;;*command-line-args* (list "/home/ocsenave/testfile.txt")
    1.12 +     pairs (if (nil? *command-line-args*) '()  (map #(re-split #" " %) (re-split #"\r\n" (slurp(first *command-line-args*)))))
    1.13 +     predecessor (reduce #(extension %1 (second %2)(first %2)) (fn[x]nil) pairs)
    1.14 +     terminus (first(remove(set(map first pairs))(map second pairs)))
    1.15 +     ]
    1.16 +  (defn lineage[x](if(nil? x)nil (cons x(lineage (predecessor x)))))
    1.17 +  (print (str-join "\n" (lineage terminus)))
    1.18 +  )
    1.19 +
    1.20 +
    1.21 +;;(if (command-line?)
    1.22 +;;  (do-something-to *command-line-args*))
    1.23 +