hi,
i was taking a look at multimethods:
(defmulti fac int)
(defmethod fac 1 [_] 1)
(defmethod fac :default [n] (*' n (fac (dec n
this works
however, this also works:
(defmulti fac print)
(defmethod fac 1 [_] 1)
(defmethod fac :default [n] (*' n (fac (dec n
what exactly is int or
Dennis Haupt d.haup...@gmail.com writes:
i was taking a look at multimethods:
(defmulti fac int)
(defmethod fac 1 [_] 1)
(defmethod fac :default [n] (*' n (fac (dec n
this works
however, this also works:
(defmulti fac print)
(defmethod fac 1 [_] 1)
(defmethod fac :default [n] (*'
i am not trying anything, i just want to figure out what happens. this is
my output for the print version:
user= (defmulti fac print)
(defmethod fac 1 [_] 1)
(defmethod fac :default [n] (*' n (fac (dec n
#'user/fac
#MultiFn clojure.lang.MultiFn@1afb02d
#MultiFn clojure.lang.MultiFn@1afb02d
Dennis Haupt d.haup...@gmail.com writes:
i am not trying anything, i just want to figure out what happens. this is my
output for the print version:
user= (defmulti fac print)
(defmethod fac 1 [_] 1)
(defmethod fac :default [n] (*' n (fac (dec n
#'user/fac
#MultiFn
yes. all glory to the repl that makes me figure out the internals via
experiments :D
is there a way to just pass the given value along?
2013/6/22 Chris Bilson cbil...@pobox.com
Dennis Haupt d.haup...@gmail.com writes:
i am not trying anything, i just want to figure out what happens. this
(ns experiments.MultiMethod)
(defmulti fac identity)
(defmethod fac 1 [n] (print n: n - ) 1)
(defmethod fac :default [n] (*' n (fac (dec n
(print (fac 125))
if i am getting this right, defmethod fac stuff [stuff2] is the
equivalent to a scala or haskell pattern match, where stuff is the match
Dennis Haupt d.haup...@gmail.com writes:
yes. all glory to the repl that makes me figure out the internals via
experiments :D
is there a way to just pass the given value along?
Yes, that's what I meant by my inspect method in my original reply. It
prints the value and passes it along:
identity :)
2013/6/22 Chris Bilson cbil...@pobox.com
Dennis Haupt d.haup...@gmail.com writes:
yes. all glory to the repl that makes me figure out the internals via
experiments :D
is there a way to just pass the given value along?
Yes, that's what I meant by my inspect method in my