Arc Forumnew | comments | leaders | submitlogin
4 points by ylando 5265 days ago | link | parent

Thanks to the remark of rocketnia. I have found some bugs in the code. Here is the code after I remove the bugs:

   (def span-let (lst)
   (if (empty lst) ()
       (mem (caar lst) binding-function-list*) 
          (list (join (car lst) (span-let (cdr lst))))   
       (and (is (type (caar lst)) 'cons) (caris (caar lst) 'scope)) ;scope
          (if (empty (cdr (car lst))) 
              (cons (caar lst) (span-let (cdr lst)))
              (cons (caar lst) (span-let (cons (cdr (car lst)) (cdr lst))))) ;forget @ after scope 
      (cons (car lst) (span-let (cdr lst)))))

  (def shuffle-numbers (min max)
  ;Get a minimum and maximum numbers
  ;Return a shuffle array of numbers from the minimum number to the maximum
  (scope
     w/table arr @
     for i 0 (- max min) 
        (= arr.i (+ i min)) @ ; init arr
     down i (- max min) 1
        (swap arr.i (arr (rand (+ 1 i)))) @  ; shuffle array elements
  ))  
Scope get a list of function calls and macro calls; so I add a macro for returning a value:

  (mac id (x) `,x)