29 Nov 2008, 23:28
Mark1_pragsmall

R. Mark Volkmann (12 posts)

On page 50 of the PDF B3
I pondered for quite a while before figuring out what (and (get chars char) idx) was doing. On the positive side, I learned about how “and” is really different from other programming languages. However, I think this example will be considerably easier to grasp if you replace that with (if (get chars char) idx).

01 Dec 2008, 12:00
Stu-small_pragsmall

Stuart Halloway (76 posts)

Hi Mark,

Thanks, I will use if in the next beta. I don’t find and to be so different from other languages, what differences do you have in mind?

01 Dec 2008, 18:26
Emerson2_pragsmall

Tom Emerson (2 posts)

I think it depends on how idiomatic you want things to be: using (and (get chars char) idx) is more Lisp like as well as emphasizing the functional nature of the language. My vote, FWIW, is to keep the example as is.

02 Dec 2008, 05:18
Technomancy_pragsmall

Phil Hagelberg (5 posts)

Using and works in other languages, but isn’t idiomatic in many.

I agree with Tom that if you understand why and is used rather than if, it helps you understand the nature of FP better. But it definitely isn’t obvious to someone coming from an imperative language; so if you want the meaning to be more obvious at first glance, if might be better. I guess it depends on where you’re going with that particular snippet.

  You must be logged in to comment