On 28 Nov., 23:29, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote:
> Hi André,
>
> Am 28.11.2008 um 22:56 schrieb André Thieme:
>
> >> Maybe I have a wrong understanding of "closure", but
> >> as far as I understand, every function definition in
> >> Clojure - be it defn or #() - finally translates t
Hi André,
Am 28.11.2008 um 22:56 schrieb André Thieme:
Maybe I have a wrong understanding of "closure", but
as far as I understand, every function definition in
Clojure - be it defn or #() - finally translates to (fn ...).
And fn creates a closure.
I tooled myself up and looked up the definiti
On 27 Nov., 13:06, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote:
Hello.
> Maybe I have a wrong understanding of "closure", but
> as far as I understand, every function definition in
> Clojure - be it defn or #() - finally translates to (fn ...).
> And fn creates a closure.
Well, from my experien
On 27 nov, 18:09, Rich Hickey <[EMAIL PROTECTED]> wrote:
> > > (defn trampoline [f]
> > > (let [ret (f)]
> > > (cond f
> > > (fn? ret) (recur ret)
> > > (instance? org.clojure.lang.NoBoingWrapper f) (.returnInstance
> > > f)
> > > else ret)))
> I considered that, and it
Rich,
I'm currently working on some code where I'm implementing state
machines where each state is a function. To move to another state,
the current state returns the function of the next state and
trampoline runs the machine through to completion. My next step is to
have each state return a va
On Nov 27, 8:37 am, lpetit <[EMAIL PROTECTED]> wrote:
> On Nov 27, 1:58 pm, lpetit <[EMAIL PROTECTED]> wrote:
>
> > and the modification of trampoline along these lines :
> > (defn trampoline [f]
> > (let [ret (f)]
> > (cond f
> >(fn? ret) (recur ret)
> >(instance? org.clo
On Nov 27, 1:58 pm, lpetit <[EMAIL PROTECTED]> wrote:
> and the modification of trampoline along these lines :
> (defn trampoline [f]
> (let [ret (f)]
> (cond f
> (fn? ret) (recur ret)
> (instance? org.clojure.lang.NoBoingWrapper f) (.returnInstance
> f)
> else ret)))
Thank you for the answer.
Could trampoline benefit for being enhanced by allowing an explicit
"escaping" for a return value of type function (that could also work
for other return types, but would not be necessary for the common
case).
Something like these :
- common usage : as usual
user=> (de
On Nov 27, 2008, at 7:13 AM, Stephen C. Gilardi wrote:
> interface "fn" that distinguishes
The interface is "clojure.lang.Fn".
--Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to
On Nov 27, 2008, at 5:21 AM, Robert Pfeiffer wrote:
> If you want to return sets, keywords, maps, or everything that
> implements the fn interface this is also an issue. Does trampolining
> on keywords make sense?
The svn revision that introduced trampoline also introduced a "marker"
interface
Hi,
On 26 Nov., 23:40, André Thieme <[EMAIL PROTECTED]> wrote:
> Maybe a simple accumulator could work here:
> user> (let [acc (ref 0)]
> (defn make-accumulator [n]
> (dosync (ref-set acc n))
> (fn [i]
> (dosync (alter acc + i)
> #'user/make-accumulator
On 26 Nov., 22:38, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> [..] Note that if you want to return a fn as a
> final value, you must wrap it in some data structure and unpack it
> after trampoline returns.
If you want to return sets, keywords, maps, or everything that
implements
On Wed, Nov 26, 2008 at 4:40 PM, André Thieme
<[EMAIL PROTECTED]> wrote:
>
> On 26 Nov., 21:26, Chouser <[EMAIL PROTECTED]> wrote:
>> On Wed, Nov 26, 2008 at 3:22 PM, Mark Volkmann
>>
>> <[EMAIL PROTECTED]> wrote:
>>
>> > I'm curious about this syntax. I thought if #(function-name args)
>> > creat
On 26 Nov., 21:26, Chouser <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 26, 2008 at 3:22 PM, Mark Volkmann
>
> <[EMAIL PROTECTED]> wrote:
>
> > I'm curious about this syntax. I thought if #(function-name args)
> > creates a closure then I can put one in a variable and execute it
> > laterI entered t
On Nov 26, 2008, at 4:32 PM, lpetit wrote:
> I've maybe missed something, but will this work if one wants to make
> the final return value of the tail call a closure ?
Along the same lines of this being a manual way to do TCO, that issue
will need to be handled manually as well. Here's what (d
On 25 nov, 15:05, Rich Hickey <[EMAIL PROTECTED]> wrote:
> To convert to a trampoline, simply return closures over your tail
> calls, rather than direct calls. This is as simple as prepending #
I've maybe missed something, but will this work if one wants to make
the final return value of the tai
On Nov 26, 2008, at 3:22 PM, Mark Volkmann wrote:
> I entered this in a REPL.
>
> (def myClosure #(prn "Hello"))
>
> How can I execute the closure in myClosure now?
Clojure
user=> (def myClosure #(prn "Hello"))
#'user/myClosure
user=> (myClosure)
"Hello"
nil
user=>
--Steve
--~--~-~--~
On Wed, Nov 26, 2008 at 3:22 PM, Mark Volkmann
<[EMAIL PROTECTED]> wrote:
>
> I'm curious about this syntax. I thought if #(function-name args)
> creates a closure then I can put one in a variable and execute it
> laterI entered this in a REPL.
>
> (def myClosure #(prn "Hello"))
>
> How can I exec
On Tue, Nov 25, 2008 at 8:05 AM, Rich Hickey <[EMAIL PROTECTED]> wrote:
big snip
> To convert to a trampoline, simply return closures over your tail
> calls, rather than direct calls. This is as simple as prepending #
>
> (declare bar)
>
> (defn foo [n]
> (if (pos? n)
>#(bar (dec n))
I'm c
Hi,
On Tuesday 25 November 2008 06:05, Rich Hickey wrote:
> I've added trampoline to ease the conversion/creation of mutually
> recursive algorithms in Clojure.
>
> ...
Clojure's new trampolines for mutually recursive functions has caught
the attention of the Scala folks. There's a nice thread
On Wed, Nov 26, 2008 at 1:00 PM, dreish <[EMAIL PROTECTED]> wrote:
>
> My favorite thing about recur is that the compiler tells you
> immediately if you accidentally put it somewhere other than in a tail
> position. You don't have to wait for the stack to overflow in actual
> use because your test
On Nov 26, 11:14 am, Rich Hickey <[EMAIL PROTECTED]> wrote:
> There's a very simple reason - such built-in trampolines are
> incompatible with interoperability. Anyone can build a trampoline
> system into their lang to get tail calls and make sure it is used
> consistently within lang - but what d
On Nov 26, 10:28 am, dreish <[EMAIL PROTECTED]> wrote:
> Now that you've gone this far, why not do this?
>
> - class clojure.lang.TailCall contains an AFn
> - Compiler checks for a tail call position and instead of calling it,
> returns new TailCall(AFn)
> - In invoke, while returnvalue instance
Now that you've gone this far, why not do this?
- class clojure.lang.TailCall contains an AFn
- Compiler checks for a tail call position and instead of calling it,
returns new TailCall(AFn)
- In invoke, while returnvalue instanceof TailCall, returnvalue =
returnvalue.fn.invoke(returnvalue)
I con
Thanks Rich,
funny, there was a post on trampoline in the Python community today :
http://davywybiral.blogspot.com/2008/11/trampolining-for-recursion.html
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" gr
Very nice. Thanks, Rich.
I had implemented my own version, but it's much nicer to have it in
the language.
Jim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to
Yes, this is superb—I was just now trying to figure out a complicated
tree zipper that mutual recursion would make needless. Thanks a lot!
On Nov 25, 11:22 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> On Nov 25, 11:07 am, Rich Hickey <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Nov 25, 10:42 a
On Nov 25, 11:07 am, Rich Hickey <[EMAIL PROTECTED]> wrote:
> On Nov 25, 10:42 am, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
>
> > On Nov 25, 2008, at 9:05 AM, Rich Hickey wrote:
>
> > > I've added trampoline to ease the conversion/creation of mutually
> > > recursive algorithms in Clojure
On Nov 25, 10:42 am, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> On Nov 25, 2008, at 9:05 AM, Rich Hickey wrote:
>
> > I've added trampoline to ease the conversion/creation of mutually
> > recursive algorithms in Clojure.
>
> Very cool! Thanks for enabling that.
>
> In looking over the imp
On Nov 25, 2008, at 9:05 AM, Rich Hickey wrote:
> I've added trampoline to ease the conversion/creation of mutually
> recursive algorithms in Clojure.
Very cool! Thanks for enabling that.
In looking over the implementation, I found a small problem: the arg
vector precedes the doc string lea
30 matches
Mail list logo