Chris Good
Chris Good

Reputation: 156

scheme: Wrong type argument in position

I'd really appreciate it if some-one can help with this. I've been banging my head for a day trying to get this to work. I've searched the internet and reread the manual but I just don't understand.

guile << __EOF__

( define heading-list (list 'a 'b 'c)
)

(define (make-heading-list)
  ( let* ((mycond #t))
     ( if mycond
       ( set! 
           heading-list
           ( append (
               heading-list
               (list 'd)
             )
           )
       )
       ( display 'false)
    )
    heading-list
  )
)

(make-heading-list)
__EOF__  

When I run this, I get:

ERROR: In procedure setter:
ERROR: In procedure setter: Wrong type argument in position 1: (a b c)

I know the formatting is non-std - I'll fix it when it works.

EDIT----------------------------------------- Here is working code (hopefully reasonably formatted now):

guile << __EOF__

(define heading-list (list 'a 'b 'c))

(define (make-heading-list)
  (let* ((mycond #t))
        (if mycond
           (set!
               heading-list
               (append heading-list (list 'd)))
           (display 'false))
         heading-list))

(make-heading-list)
__EOF__

Upvotes: 3

Views: 2478

Answers (1)

Michael Vehrs
Michael Vehrs

Reputation: 3373

heading-list is a list. You are using it as if it were a procedure. (heading-list) means "apply procedure heading-list to zero arguments". Hence the error message "wrong type to apply".

Upvotes: 2

Related Questions