(define foo
(+ 4 5))
But (foo) gives:
function call: expected a defined name or a primitive operation name
after an open parenthesis, but found something else
Is this just not supported in the Beginning Student language?
I ended up just passing a defined variable to each function and used
it as a passed variable instead of a "global".
(foo DEF_COLOR)
--
Geoff Lane <ge...@zorched.net>
(define (foo)
(+ 4 5))
but in Beginning Student language I get:
define: expected at least one argument name after the function name,
but found none
I tried all the languages from Beginning Student upward, and it wasn't
until Advanced Student that I could create a "thunk" -- a procedure
with zero arguments.
The syntax you used, (define foo (+ 4 5)), does not create a
function. It computes the sum of 4 and 5, namely 9, and binds the
symbol foo to that value. In a conventional language, the equivalent
of what you did is:
foo = 4 + 5;
foo(); // maybe John Lennon knows what function 9 is ("Number 9,
number 9, ....")
Geoff's with a G of the world unite! :)
I guess I should have mentioned I tried that first, but it caused a
syntax error as you pointed out.
This is an interesting part about something like HTDP to me as a
non-beginner. It's in trying to "forget what you know" and only
program with the current tools you have. That exercise in constraint
based programming (where the constraints are the constructs you have
available) really makes you rethink some things.
Now I'm also curious what a true beginner feels as they go through
this and peel back the layers of the onion as more and more things are
exposed. It's just so different from how I learned - originally Basic,
Pascal and C++.
Thunk:
http://en.wikipedia.org/wiki/Thunk
--
Geoff Lane <ge...@zorched.net>
-B
A problem is a large (or infinite) family of questions that share some features and differ in others. A program (or function) is a general rule for solving a problem with input(s) for the features that differ. You write programs/functions to solve problems. Problems, by definition, encapsulate a large number of questions by using inputs to drive the computation.