Discussion:
Learining recursion using "The little schemer"
(too old to reply)
G***@gmail.com
2009-05-23 08:27:53 UTC
Permalink
Hi functional minds :-), i'm a young student with a little background
in imperative languages (Java / C++)
and i would learn to "master" recursion and something about the
functional paradigm, i'm reading "The little schemer" but i have
difficulties to execute the examples proposed in the first chapter(i
have understood semantics behind car, cdr, cons...). I'm using
DrScheme :) and i don't know how to create a binding with l a symbol
and a list (i have no knowledge of scheme programming language).

How to execute this snippet in DrScheme?
(car (cdr l))
where l is ((b) (xy) ((c)))

Can you give me some advices about learning functional paradigm?
Should I learn scheme first before go read The little schemer(i love
the author's style)?

Thanks suggestions are really appreciated. :)

N.B. Sorry for my english, i must improve...
G***@gmail.com
2009-05-23 17:12:44 UTC
Permalink
Post by G***@gmail.com
Hi functional minds :-), i'm a young student with a little background
in imperative languages (Java / C++)
and i would learn to "master" recursion and something about the
functional paradigm, i'm reading "The little schemer" but i have
difficulties to execute the examples proposed in the first chapter(i
have understood semantics behind car, cdr, cons...). I'm using
DrScheme :) and i don't know how to create a binding with l a symbol
and a list (i have no knowledge of scheme programming language).
How to execute this snippet in DrScheme?
(car (cdr l))
where l is ((b) (xy) ((c)))
Can you give me some advices about learning functional paradigm?
Should I learn scheme first before go read The little schemer(i love
the author's style)?
Thanks suggestions are really appreciated. :)
N.B. Sorry for my english, i must improve...
I have found a very helpful manual on the web
"Teach yourself scheme in fixnum days" that briefly
shows how to create a list...I think that the first
chapter was written to execute questions in reader's mind.
George Neuner
2009-05-24 05:59:44 UTC
Permalink
On Sat, 23 May 2009 01:27:53 -0700 (PDT),
Post by G***@gmail.com
Hi functional minds :-), i'm a young student with a little background
in imperative languages (Java / C++)
and i would learn to "master" recursion and something about the
functional paradigm, i'm reading "The little schemer" but i have
difficulties to execute the examples proposed in the first chapter(i
have understood semantics behind car, cdr, cons...). I'm using
DrScheme :) and i don't know how to create a binding with l a symbol
and a list (i have no knowledge of scheme programming language).
How to execute this snippet in DrScheme?
(car (cdr l))
where l is ((b) (xy) ((c)))
The simplest ways are to type at the REPL:

(define l '((b) (xy) ((c))))
(car (cdr l))

or

(let (( l '((b) (xy) ((c))) ))
(car (cdr l)))

Note the second example is one expression wrapped onto 2 lines. Also
note the extra doubled parentheses around the binding ... whereas
"define" binds a single symbol, "let" binds a list of symbols - the
extra parentheses demarcate the binding list from the body of the let
expression. There are other differences between "define" and "let"
but you don't need to know them just now.

Note: the apostrophes (\' - generally read aloud as "tick") in the
above examples denote a literal (ie. unevaluated) value. When an
entire list is marked as a literal, a Scheme compiler is allowed to
make the list read-only. If you want your list to be modifiable you
have to construct it programmatically using either "cons" or "list",
as in:

(list (list 'b) (list 'xy) (list (list 'c)))

or

(cons (cons 'b '())
(cons (cons 'xy '())
(cons (cons 'c '()) '()) '()) '())

Here only the symbols are literal. "'()" denotes an empty list.
"car" and "cdr" only read the list, so using the tick notation on the
whole list is safe.
Post by G***@gmail.com
Can you give me some advices about learning functional paradigm?
Should I learn scheme first before go read The little schemer(i love
the author's style)?
The Little Schemer is a good book, but it won't necessarily teach you
the language. The book concentrates more on teaching functional
programming concepts. WRT Scheme, it spends most of its time on
either really primitive stuff or on really advanced stuff and not much
in between.

IMO, I think you'd be better served by taking a couple of weeks to
learn Scheme first. Scheme is quite simple to learn and reasonable
facility with a significant portion of the language should take only a
few weeks. DrScheme has an excellent Scheme tutorial and a companion
book, "How To Design Programs", available online at www.htdp.org.

George
G***@gmail.com
2009-05-24 09:33:46 UTC
Permalink
Post by George Neuner
On Sat, 23 May 2009 01:27:53 -0700 (PDT),
Post by G***@gmail.com
Hi functional minds :-), i'm a young student with a little background
in imperative languages (Java / C++)
and i would learn to "master" recursion and something about the
functional paradigm, i'm reading "The little schemer" but i have
difficulties to execute the examples proposed in the first chapter(i
have understood semantics behind car, cdr, cons...). I'm using
DrScheme :) and i don't know how to create a binding with l a symbol
and a list (i have no knowledge of scheme programming language).
How to execute this snippet in DrScheme?
(car (cdr l))
where l is ((b) (xy) ((c)))
     (define l '((b) (xy) ((c))))
     (car (cdr l))
or
     (let (( l '((b) (xy) ((c))) ))
        (car (cdr l)))
Note the second example is one expression wrapped onto 2 lines.  Also
note the extra doubled parentheses around the binding ... whereas
"define" binds a single symbol, "let" binds a list of symbols - the
extra parentheses demarcate the binding list from the body of the let
expression.  There are other differences between "define" and "let"
but you don't need to know them just now.
Note: the apostrophes (\' - generally read aloud as "tick") in the
above examples denote a literal (ie. unevaluated) value.  When an
entire list is marked as a literal, a Scheme compiler is allowed to
make the list read-only.  If you want your list to be modifiable you
have to construct it programmatically using either "cons" or "list",
   (list (list 'b) (list 'xy) (list (list 'c)))
or
   (cons (cons 'b '())
         (cons (cons 'xy '())
               (cons (cons 'c '()) '()) '()) '())
Here only the symbols are literal. "'()" denotes an empty list.
"car" and "cdr" only read the list, so using the tick notation on the
whole list is safe.
Post by G***@gmail.com
Can you give me some advices about learning functional paradigm?
Should I learn scheme first before go read The little schemer(i love
the author's style)?
The Little Schemer is a good book, but it won't necessarily teach you
the language.  The book concentrates more on teaching functional
programming concepts.  WRT Scheme, it spends most of its time on
either really primitive stuff or on really advanced stuff and not much
in between.
IMO, I think you'd be better served by taking a couple of weeks to
learn Scheme first.  Scheme is quite simple to learn and reasonable
facility with a significant portion of the language should take only a
few weeks.  DrScheme has an excellent Scheme tutorial and a companion
book, "How To Design Programs", available online atwww.htdp.org.
George
Thanks for your help and explanations George :) yesterday i have
finished the first chapter
and i have found no particular difficulties. However i haven't
understood the real difference
between a literal or a symbol before your mail. I prefer learning by
doing and HTDP seems
an enjoyable book but there are no pet projects, do you know a book
about functional paradigm
(the language is not important for me) that start from the beginning
teaching functional concepts
and go on with a little project that shows how to apply the functional
concepts to solve the problem?
Paul Rubin
2009-05-24 14:29:16 UTC
Permalink
do you know a book about functional paradigm (the language is not
important for me) that start from the beginning teaching functional
concepts and go on with a little project that shows how to apply the
functional concepts to solve the problem?
For Scheme I'd start with SICP (http://mitpress.mit.edu/sicp)

For Haskell, Real World Haskell (http://book.realworldhaskell.org)
Benjamin L. Russell
2009-05-25 06:00:58 UTC
Permalink
On 24 May 2009 07:29:16 -0700, Paul Rubin
Post by Paul Rubin
do you know a book about functional paradigm (the language is not
important for me) that start from the beginning teaching functional
concepts and go on with a little project that shows how to apply the
functional concepts to solve the problem?
For Scheme I'd start with SICP (http://mitpress.mit.edu/sicp)
One alternative to SICP is _Concrete Abstractions,_ by Max Hailperin,
Barbara Kaiser, and Karl Knight; see the following Web sites for
details:

Concrete Abstractions (Web site):
http://gustavus.edu/+max/concrete-abstractions.html

ConcreteAbstractions.pdf:

http://gustavus.edu/+max/concrete-abstractions-pdfs/ConcreteAbstractions.pdf

Using Concrete Abstractions with DrScheme:
http://gustavus.edu/+max/concabs/schemes/drscheme/

_Concrete Abstractions_ takes a more old-school (as in exploratory
programming style) approach to programming, somewhat similar to that
of SICP, albeit at a less challenging pace, than that of _How to
Design Programs_ (HtDP). HtDP's approach is very different, taking a
systematic, rather than exploratory, approach, and approaching
functional programming as a step toward object-oriented programming.
However, HtDP proceeds *extremely slowly*, especially at the
beginning.

If you like the exploratory approach of SICP, but feel overwhelmed and
would prefer a somewhat reduced pace, try _Concrete Abstractions_; on
the other hand, if you wish to have the book lead you by the hand
systematically, spelling out most of the details, and eventually
leading you toward the object-oriented approach, try HtDP.

There is also a comparison of several different books concerning the
Scheme programming language at the following blog entry:

A Scheme bookshelf << programming musings
http://programming-musings.org/2007/01/31/a-scheme-bookshelf/

However, I would take some of the comments by the above-mentioned blog
poster with somewhat of a grain of salt; in particular, he writes as
Post by Paul Rubin
[I] got a copy of The Little Schemer$B!D(B to no avail: i didn$B!G(Bt get what elephants,
food and Socrates had to do with programming; i still felt awkward. (It was not
the book$B!G(Bs fault, mind you, but mine. More about this in a bit.)
How comfortable that you feel with _The Little Schemer_ will probably
depend at least partially on your background; the less exposure that
you have to procedural, and the more exposure you have to functional,
programming, the easier it will be to digest the concepts. Those with
a background in a dialect of Scheme, Lisp, or a functional programming
language will probably digest the concepts more easily, but the book
does not assume that kind of background. To me, its approach reminded
me of the adventures of Alice in _Alice's Adventures in Wonderland_
and _Through the Looking Glass,_ sparking my curiosity on every page,
and was quite a fun journey.
Post by Paul Rubin
For Haskell, Real World Haskell (http://book.realworldhaskell.org)
Another title on Haskell that I would recommend is _Programming in
Haskell,_ by Graham Hutton (see
http://www.cs.nott.ac.uk/~gmh/book.html). Duncan Coutts has written a
book review on this title, in which he highly recommends the book, at
http://www.cs.nott.ac.uk/~gmh/book-review.pdf. Unlike most books and
tutorials on Haskell, neither RWH nor _Programming in Haskell_ assumes
that the reader is highly mathematically-inclined.

-- Benjamin L. Russell
--
Benjamin L. Russell / DekuDekuplex at Yahoo dot com
http://dekudekuplex.wordpress.com/
Translator/Interpreter / Mobile: +011 81 80-3603-6725
"Furuike ya, kawazu tobikomu mizu no oto."
-- Matsuo Basho^
Loading...