[REBOL] Re: Noob with a question
From: petr:krenzelok:seznam:cz at: 26-Mar-2009 6:08
mumpsoid-gmx.com napsal(a):
> Hi.....
>
> I'm a new-guy in the REBOLution ;)
>
Hello and welcome! :-)
> At 62, I may be too old to make a good REBOLutionary, but I suppose
> that advocacy is ageless. I'm a self-taught, amateur Perl and M(umps)
> programmer. I've also had a long, hard look at Forth. I see in REBOL
> what appears to be "some" Forth influence. Could I be correct?
>
You are never too old to start with REBOL :-) As for Forth influence -
yes, some ppl believe it has some influence in Forths (especially
dialects), some do find some similarities in Lisp, even calling REBOL
being a deparenthetised Lisp .... but - REBOL is special, not strictly
functional language ...
> Anyway, so far I really enjoy REBOL - it's dead easy and very
> intuitive. I'm using /Core on an OS X Intel box running the latest
> Leopard patch. I don't believe /View will work on my machine.
>
Hopefully some OS-X guys step in with the answer, but IIRC even View
should work on OS-X?
> Question:
> The manual states:
>
> The forall advances the variable position through the series, so when
> it returns the variable is left at its tail:
>
> Therefore, the variable must be reset before it is used again:
>
Not sure it has to:
->> forall colors [print first colors print index? colors]
red
1
green
2
blue
3
->> index? colors
== 1
So, when out of the loop, the colors block is once again at its
beginning. Even in a loop itself, it does not reach tail. I suggest
following chapter describing how series positioning works. It is
fundamental to understand it:
http://www.rebol.com/docs/core23/rebolcore-6.html
> However. when I try it out I get:
>
> >>
> >> colors: [red green blue yellow orange]
> == [red green blue yellow orange]
> >>
> >> forall colors [print first colors]
> red
> green
> blue
> yellow
> orange
> >>
> >> print tail? colors
> false
>
As for me, I don't use forall much. I prefer foreach and for loops.
Foreach when you don't need to know a position, just:
foreach color colors [print color]
And when I need to know the position, then I use old-school for loop :-)
for color 1 length? colors 1 [print colors/:color]
> Thanks for the help and a great language!
>
Once again - welcome here and enjoy! We have small community, but some
ppl say very helpful :-)
-pekr-