It is quite easy to write a macro define in clojure that does that:
(defmacro define [head & body]
(if (sequential? head)
`(define ~(first head) (fn [ ~@(rest head)] ~@body))
`(def ~head ~@body)))
(define ((A [p1 p2]) [p3 p4]) [p2 p4]))
((A [1 2]) [3 4]) => [2 4]
--
You recei
That statement of mine was confusing because if you type each you'll get
different things.
The equivalence of (define (foo) bar) === (define foo (lambda() bar)) won't
hold there: you'd be defining procedure A in the second case.
If the first argument is in parens, (define) will be a function def
Would an idiomatic definition of ((A)) be (defn fnA [] #(A))?
(defn a [] [:a :b])
(a)
; (a => fn) => [:a :b]
(defn funcA [] #(a))
(funcA)
; (funcA => fn)
((funcA))
; ((funcA)) => [:a :b]
Where you define a function which, when invoked, returns a function which,
when invoked, invokes A? This is a
Let's focus on that for a sec:
(define ((A)) 1) is the same as (define (A) (lambda () 1));;
defines procedure "(A)"
I wonder if you meant >>defines procedure "((A))"<< instead.
Assuming that, if "((A))" is just a name of the procedure, then
"A" and "(A)". Should not evaluate at all. Appa
Let's take it case by case.
(define A 1) is like (def A 1) in Clojure.
(define (A) 1) is like (defn A [] 1)
(define (A x y) (* x y)) as you'll expect, (defn A [x y] (* x y))
(define (A) 1) is the same as (define A (lambda () 1)) ;; defines
procedure "A"
(define ((A)) 1) is the same as (def
On Thu, Aug 30, 2012 at 5:48 PM, Andy Coolware wrote:
> I use Rocket Scheme. The question was inspired by "Structure and
> Interpretation" http://www.youtube.com/watch?v=2Op3QLzMgSY at almost
> end of the video @ 1:11:11
>
> I actually think that "((A))" is more just a symbol name since
> appar
I use Rocket Scheme. The question was inspired by "Structure and
Interpretation" http://www.youtube.com/watch?v=2Op3QLzMgSY at almost
end of the video @ 1:11:11
I actually think that "((A))" is more just a symbol name since
apparently you define "A" not a "((A))"/ It is more like a
recursive/ne
That's the definition of a procedure named "(A)". Scheme48, for one, won't
take that name, but Chicken will, even with parameters:
#;1> (define ((A) n) n)
#;2> ((A) 5)
5
And neither will, btw, bind a value to such a symbol in a (let). Clojure
symbols can't start with an open paren, so that's just
On Wed, Aug 29, 2012 at 10:14 PM, Baishampayan Ghose wrote:
> Something like this?
>
> (defn A []
> 1)
>
> (defn A []
> (fn [] 1))
That would work but I wonder about how "(define ((A)) 1)" is evaluated
in Scheme and why similar and easier approach is not possible in
Clojure?
--
You received
Something like this?
(defn A []
1)
(defn A []
(fn [] 1))
Regards,
BG
On Thu, Aug 30, 2012 at 10:41 AM, Andy Coolware wrote:
>> (define (A) 1)
> #
>> A
> #
>> (A)
> 1
>> (define ((A)) 1)
> #
>> A
> #
>> (A)
> #
>> ((A))
> 1
>
> Just wondering ...
>
> Andy
>
> --
> You received this message
> (define (A) 1)
#
> A
#
> (A)
1
> (define ((A)) 1)
#
> A
#
> (A)
#
> ((A))
1
Just wondering ...
Andy
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are
11 matches
Mail list logo