[CM] Loop collecting list elements in Sal

Torsten Anders torsten.anders at beds.ac.uk
Mon May 2 08:37:05 PDT 2011

Dear Rick,

I am probably missing something rather simple, but I am unable to write a loop in Sal where the accumulated results are returned and bound to a variable. For example, how can I translate the following Scheme code into Sal?

(define test
  (loop for i from 1 to 10
      collect i))

Alternatively, how do I translate the following? 

(define test
  (loop with res = '()
      for i from 1 to 10
      (set! res (cons i res))
      finally (return res)))

When I translate it then the variable test remains undefined.

Thank you! 


More information about the Cmdist mailing list