PasteRack.org
Paste # 54441
2018-05-09 10:12:22

Fork as a new paste.

Paste viewed 156 times.


Embed:

  1. #lang racket
  2. (define (random-by l)
  3.   (define r (random))
  4.   (for/fold ([sum 0] [i 0] #:result (- i 1))
  5.             ([c l])
  6.     #:break (> sum r)
  7.     (values (+ sum c) (+ i 1))))

=>

eval:2:0: for/fold/derived: bad syntax

  in: (for/fold/derived (for/fold ((sum 0) (i 0) #:result (-

i 1)) ((c l)) #:break (> sum r) (values (+ sum c) (+ i 1)))

((sum 0) (i 0) #:result (- i 1)) ((c l)) #:break (> sum r)

(values (+ sum c) (+ i 1)))