Re: [frogs] Guitar capo code in scheme

[ Thread Index | Date Index | More lilynet.net/frogs Archives ]


On 7/25/11 6:16 PM, "Wols Lists" <antlists@xxxxxxxxxxxxxxx> wrote:

> On 25/07/11 23:16, Carl Sorensen wrote:

>> 
>> One -- you were missing an opening paragraph after one of the let
>> statements.
> 
> Sounds a bit like PL/1 :-)

Oops, I meant parenthesis.  Getting senile is tough!

>> 
>> Two -- you needed a let* instead of a let
> 
> I noticed Neil used a let*, and wondered about that ... what is a let*,
> and what's the difference between that and a let?

let* is like let, but in let* a variable that is defined can be used later
on.

So

(let ((var1 10)
      (var2 (+ var1 10)))

will throw an error for "undefined variable var1"

but 

(let* ((var1 10)
       (var2 (+ var1 10)))

will set the value of var1 to 10 and var2 to 20.


>> 
>> So in C, you can add extra parentheses.  In Scheme, you can't.
> 
> Ah. And it is pretty much standard, in C and Fortran, to enclose your
> conditional in parentheses (indeed, in Fortran, I think you have to...)

Yes, that's true.  When working in Scheme, don't think of parentheses as
grouping operators, like in FORTRAN or C.  Parentheses in Scheme bound
expressions; the first element in a parenthesis-bounded expression *must* be
an evaluatable symbol (e.g. a procedure or an operator).

> Ta muchly,

No problem.  I remember the first days of trying to wade through Guile and
LilyPond.  It can be challenging....


Carl


---
----
Join the Frogs!


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/