"identity" :)
2013/6/22 Chris Bilson
> Dennis Haupt 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 th
Dennis Haupt 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:
(defn inspect [
(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 [] is the
equivalent to a scala or haskell pattern match, where stuff is the "match"
and
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
> Dennis Haupt writes:
>
> > i am not trying anything, i just want to figure out what happens. this
> is my output for the "print" vers
Dennis Haupt 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
> #
> #
> user=> (fac 1)
> 10-1-2-3-4-5-6
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
#
#
user=> (fac 1)
10-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20-21-2
Dennis Haupt 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] (*' n (fac (
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 "pr