PasteRack.org
Paste # 19632
2019-11-29 16:51:34

Fork as a new paste.

Paste viewed 563 times.


Embed:

  1. #lang racket/base
  2.  
  3. (require syntax/parse/define)
  4.  
  5. (define-simple-macro (for*/max clauses body ... tail-expr)
  6.   (for*/fold/derived this-syntax ([ans -inf.0])
  7.     clauses
  8.     body ...
  9.     (max ans tail-expr)))
  10.  
  11. (define a (vector 4 3 1 5 2 6 2 8))
  12. (for*/max ([i (in-range (vector-length a))]
  13.            [j (in-range (add1 i) (vector-length a))])
  14.   (- (vector-ref a i) (vector-ref a j)))

=>

4.0