# Posted By

narkisr on 06/04/09

# Statistics

Viewed 749 times
Favorited by 0 user(s)

# Viewing source & type methods in Clojure REPL

/ Published in: Lisp
Save to your folder(s)

Clojure contribe repl-utils offers two functions for locating the source code of functions & the method of types (http://groups.google.com/group/clojure/browse_thread/thread/77f95518fcfc8a08/5de8ef8ff8f3b3bd?lnk=gst&q=source#5de8ef8ff8f3b3bd).

Copy this code and paste it in your HTML
`user=> (use 'clojure.contrib.repl-utils) ; shows the source of the filter methoduser=> (source filter)(defn filter  "Returns a lazy sequence of the items in coll for which  (pred item) returns true. pred must be free of side-effects."  [pred coll]  (let [step (fn [p c]                 (when-let [s (seq c)]                   (if (p (first s))                     (cons (first s) (filter p (rest s)))                     (recur p (rest s)))))]    (lazy-seq (step pred coll)))) ; shows all the methods of Clojure ratio typeuser=> (show 1/2)===  public clojure.lang.Ratio  ===[ 0] <init> (BigInteger,BigInteger)[ 1] denominator : BigInteger[ 2] numerator : BigInteger[ 3] byteValue : byte ()[ 4] compareTo : int (Object)[ 5] decimalValue : BigDecimal ()[ 6] decimalValue : BigDecimal (MathContext)[ 7] doubleValue : double ()[ 8] equals : boolean (Object)[ 9] floatValue : float ()[10] getClass : Class ()[11] hashCode : int ()[12] intValue : int ()[13] longValue : long ()[14] notify : void ()[15] notifyAll : void ()[16] shortValue : short ()[17] toString : String ()[18] wait : void ()[19] wait : void (long)[20] wait : void (long,int)`