Author |
Message |
kijjaz
Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Tue Aug 29, 2006 4:17 pm Post subject:
<<< chuck >>> Subject description: printing in chuck |
|
|
Code: | // what'd it print out? eh.. i'm confused with this one
<<< <<< <<<0>>>, <<<1>>> >>> , <<< <<<2>>>, <<<3>>> >>> >>>; |
i'm using chuck 1.2.0.6 (dracula)
i've got this result:
Code: | 0 :(int)
1 :(int)
0 1
2 :(int)
3 :(int)
2 3
2 3 |
i can't figure out how the last line 2 3 is computed from..
please help me out heheh..
actually i was playing with <<< >>>
and wanna know what more we can do with it.
i guess there must be a lot of fun way we can play with printing. |
|
Back to top
|
|
|
ge
Joined: Aug 13, 2006 Posts: 108 Location: Palo Alto, CA
|
Posted: Wed Aug 30, 2006 12:26 am Post subject:
Re: <<< chuck >>> Subject description: printing in chuck |
|
|
Code: | // what'd it print out? eh.. i'm confused with this one
<<< <<< <<<0>>>, <<<1>>> >>> , <<< <<<2>>>, <<<3>>> >>> >>>; |
Interesting usage! The reason this works is because it was designed to work "out of band", so you can more easily observe subexpressions.
Code: | // the expression
3 + foo * x => bar;
// print out foo * x and still evaluate
3 + <<< foo * x >>> => bar; |
It is not completely neutral to the expression. It's possible to change the precedent of the evaluation. Anyway, this is the first time I've seen <<< >>> nested. Cool!
Once file I/O is in, there will be many more ways of printing and writing to file. |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24085 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Wed Aug 30, 2006 2:58 am Post subject:
|
|
|
I had expected the last output lune would have been
0 1 2 3
instead of
2 3 _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
kijjaz
Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Wed Aug 30, 2006 3:12 am Post subject:
|
|
|
Blue Hell: hello
yeah, that's what i thought also.
that's what i'm still figuring out. hehehe..
oh i'm back!
yeah, i've figured it out.
expression , expression returns the last expression
try <<< <<< 1, 2 >>> >>>;
my result:
1 2
2 :(int)
1, 2 => int k; <<< k >>>; returns the same kind of 2 as the above.
maybe this is how it works that way. |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24085 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Wed Aug 30, 2006 4:27 am Post subject:
|
|
|
kijjaz wrote: |
expression , expression returns the last expression
|
Well I thought that as well at some stage (and I think I read something about it in a manual or a tutorial), but in that case I would have expected the output to be :
0
1
1
2
3
3
3 _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
kijjaz
Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Wed Aug 30, 2006 4:49 am Post subject:
|
|
|
(i guess again:) but surely with an exception that
<<< ___ , ___ , ___ >>>; will print the list out
but the value returned after printing is the last expression. |
|
Back to top
|
|
|
kijjaz
Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Tue Sep 12, 2006 8:32 am Post subject:
|
|
|
wow.. this works like this..
i'll try to figure this out also hahah.
code:
Code: | <<<
<<< <<< <<< "<<< >>>" >>> , <<< "<<< >>>" >>> >>> >>>,
<<< <<< <<< "<<< >>>" >>> , <<< "<<< >>>" >>> >>> >>>
>>>; |
result:
Code: | "<<< >>>" : (string)
"<<< >>>" : (string)
<<< >>> <<< >>>
"<<< >>>" : (string)
"<<< >>>" : (string)
"<<< >>>" : (string)
<<< >>> <<< >>>
"<<< >>>" : (string)
<<< >>> <<< >>> |
... oh! it's the same case and same method.
i was confused lol. |
|
Back to top
|
|
|
|