Re: ERROR: Bad define placement

2010-11-23 Thread barry stevensson
Thank you very much Neil and Thien-Thi, it works :-)

Barry

On Mon, Nov 22, 2010 at 10:24 PM, Thien-Thi Nguyen t...@gnuvola.org wrote:

 () Neil Jerram n...@ossau.uklinux.net
 () Mon, 22 Nov 2010 20:26:49 +

   Fingers crossed...

 The pertinent area of difficulty seems to be:

 --8---cut here---start-8---
 (let f1 ((kzluw 0.5))
  (define (kxmin zvalue1) (- 0.75 (* zvalue1 0.5)))

  (let f2 ((kxluw (kxmin kzluw)))
 (define (kyluw xx zz) (- 1.5 (+ xx zz)))
 (define (kxmax zvalue2) (- 1 zvalue2))

 ...
 --8---cut here---end---8---

 In all these cases, the new variables introduced by ‘f1’
 and ‘f2’ (i.e., ‘kzluw’ and ‘kxluw’, respectively) are
 not used by the inner procedures ‘kxmin’, ‘kyluw’, ‘kxmax’.
 To my eyes, it would be best to lift those procedures to
 top level, like so:

 --8---cut here---start-8---
 (define (kxmin zvalue1)
  (- 0.75 (* zvalue1 0.5)))

 (define (kyluw xx zz)
  (- 1.5 (+ xx zz)))

 (define (kxmax zvalue2)
  (- 1 zvalue2))

 (let f1 ((kzluw 0.5))
   (let f2 ((kxluw (kxmin kzluw)))
 ...
 --8---cut here---end---8---

 That's a matter of style, though, not of correctness.
 I'm sure there's a Seasoned Schemer commandment somewhere
 regarding this.  Some other (very minor) style nits:

 ok:  (- 1.5 (+ xx zz))
  better:  (- 1.5 xx zz)

 ok:  (if COND THEN)
  better:  (and COND THEN)  /  (or (not COND) THEN)

 Not to mention whitespace before close-paren




Re: ERROR: Bad define placement

2010-11-22 Thread Neil Jerram
barry stevensson brrstvns...@googlemail.com writes:

 Can anyone  help me please ...  i need your help badly.

It's always a good idea to CC the list, so that more people can
potentially help you.  I've added guile-user on CC here.

 Or at least guide where
 should i have a look to figure out the mistake...

I've attached what I think your code should be, with the defines in the
correct place.  Can you review (for safety) and then try out my version,
to see if it works any better than yours?  If it does, you can then look
at where our versions are different.

FYI, I did a couple of things to get your code into a more conventional
form:

1. I replaced several strange characters (ASCII code 160) with spaces.
It's possible that these characters were the cause of the problem.  If
you aren't already, please try using a proper programming editor (such
as emacs or vi) to write your code - that should help to avoid
introducing such characters.

2. I used emacs's indent-region function to indent the code
conventionally.  This has no effect on the operation of the code, but
makes it easier for me and others to read.

Fingers crossed...

   Neil



barry.scm
Description: Binary data


Re: ERROR: Bad define placement

2010-11-22 Thread Thien-Thi Nguyen
() Neil Jerram n...@ossau.uklinux.net
() Mon, 22 Nov 2010 20:26:49 +

   Fingers crossed...

The pertinent area of difficulty seems to be:

--8---cut here---start-8---
(let f1 ((kzluw 0.5))
  (define (kxmin zvalue1) (- 0.75 (* zvalue1 0.5)))

  (let f2 ((kxluw (kxmin kzluw)))
(define (kyluw xx zz) (- 1.5 (+ xx zz)))
(define (kxmax zvalue2) (- 1 zvalue2))

...
--8---cut here---end---8---

In all these cases, the new variables introduced by ‘f1’
and ‘f2’ (i.e., ‘kzluw’ and ‘kxluw’, respectively) are
not used by the inner procedures ‘kxmin’, ‘kyluw’, ‘kxmax’.
To my eyes, it would be best to lift those procedures to
top level, like so:

--8---cut here---start-8---
(define (kxmin zvalue1)
  (- 0.75 (* zvalue1 0.5)))

(define (kyluw xx zz)
  (- 1.5 (+ xx zz)))

(define (kxmax zvalue2)
  (- 1 zvalue2))

(let f1 ((kzluw 0.5))
  (let f2 ((kxluw (kxmin kzluw)))
...
--8---cut here---end---8---

That's a matter of style, though, not of correctness.
I'm sure there's a Seasoned Schemer commandment somewhere
regarding this.  Some other (very minor) style nits:

 ok:  (- 1.5 (+ xx zz))
 better:  (- 1.5 xx zz)

 ok:  (if COND THEN)
 better:  (and COND THEN)  /  (or (not COND) THEN)

Not to mention whitespace before close-paren



Re: ERROR: Bad define placement

2010-11-17 Thread Neil Jerram
barry stevensson brrstvns...@googlemail.com writes:

 ERROR: In procedure memoization:
 ERROR: Bad define placement (define (kxmax zvalue2) (- 1 zvalue2)).

Just move the `(define (kxmax zvalue2) (- 1 zvalue2))' line so that it
comes directly after `(define (kyluw xx zz) (- 1.5 (+ xx zz)))'.  Scheme
doesn't allow that define where you currently have it - see R5RS section
5.2.

(At least, it's 5.2 in the copy of R5RS that comes with Guile; I haven't
checked other versions.)

 Neil