>>As a group, *1, *2, and *3 form (effectively) a small queue (not a  stack as 
>>someone mentioned previously).
It was me :)

On Jan 15, 3:00 pm, "Stephen C. Gilardi" <squee...@mac.com> wrote:
> On Jan 15, 2009, at 7:28 AM, HB wrote:
>
> > Do *1 *2 *3 ... are saved in a built in sequence that we can inspect  
> > its contents?
>
> No, they are separate vars. Here's the code from the core of the read-
> eval-print loop in clojure/src/clj/clojure/main.clj that shows how  
> they're updated:
>
>               (let [input (read)]
>                 (skip-if-eol *in*)
>                 (let [value (eval input)]
>                   (print value)
>                   (set! *3 *2)
>                   (set! *2 *1)
>                   (set! *1 value)))
>
> As a group, *1, *2, and *3 form (effectively) a small queue (not a  
> stack as someone mentioned previously). If at any point, you want to  
> see all three together, you can evaluate an expression that puts them  
> all in a vector:
>
>         Clojure
>         user=> :a
>         :a
>         user=> :b
>         :b
>         user=> :c
>         :c
>         user=> :d
>         :d
>         user=> [*1 *2 *3]
>         [:d :c :b]
>
> Note that evaluating the vector makes that the new "most recent  
> value": it causes a new "*1" to be pushed into the queue:
>
>         user=> [*1 *2 *3]
>         [[:d :c :b] :d :c]
>         user=>
>
> --Steve
>
>  smime.p7s
> 3KViewDownload
--~--~---------~--~----~------------~-------~--~----~
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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to