[squeak-dev] Terse Guide for Squeak

Juan Vuletich juan at jvuletich.org
Fri Nov 26 20:05:43 UTC 2010


David T. Lewis wrote:
> ...
>
> Well, hopefully it will be useful for us recovering Fortran and
> C programmers ;-)
>
> Let me issue two follow up challenges, since I could not figure
> these out on my own:
>
> 1) It would be good to add a terse one-line expression that would show
> the use of block closures. What is the shortest meaningful expression
> that illustrates this?
>   

They allow functional style code to work properly. For example:

    fac := [ :n | n > 1 ifTrue:  n * (fac value: n-1)] ifFalse: [1]].
    fac value: 5. "120"

and

    fib := [ :n | n < 2 ifTrue: [1] ifFalse: [(fib value: n-1) + (fib 
value: n-2)]].
    fib value: 10. "89"

Cheers,
Juan Vuletich

> 2) It would be nice if the pages in the help book could be set to
> behave like workspaces, with syntax formatting and workspace
> variables. Can anyone think of a way to do it?
>
> Dave
>
>   




More information about the Squeak-dev mailing list