Arc Forumnew | comments | leaders | submitlogin
Some Racket utilities, at Lathe (github.com)
2 points by rocketnia 5236 days ago | 1 comment


2 points by rocketnia 5236 days ago | link

I threw together these Racket utilities just to learn about Racket macros. Plenty of other utility libraries exist, and you should probably look for those instead if you're interested. :-p

These utilities aren't extensible (kind of a must for me, nowadays). Furthermore, they're not built to have especially nice error messages. ^_^;

What they are is slightly more convenient, of course. A lot of them are inspired by Arc or my Penknife draft, but they're not comprehensive takes on Arc or Penknife by any means. Mostly, they save parentheses.

  ; before
  (begin 1 2 3)
  
  ; after
  (du 1 2 3)  ; "do" was taken (yeah, silly example)
  
  
  ; before
  (cond [(plan-a)  4]
        [(plan-b)  5]
        [else      6])
  
  ; after
  (ifs (plan-a)  4
       (plan-b)  5
                 6)
  
  
  ; before
  (let* ([a 1] [b 2])
    (display "hi")
    (let ([c 3])
      (+ a b c)))
  
  ; after
  (w- a 1 b 2
    (display "hi")
      c 3
    (+ a b c))
  
  
  ; before
  (foo (bar 3 (baz (qux 1 2 3))))
  
  ; after
  (: foo : bar 3 : baz : qux 1 2 3)
  
  
  ; before
  (lambda (a b) (string<? (car a) (car b)))
  
  ; after
  (: abfn : string<? (car a) (car b))
  
  
  ; before
  (let next ([a 1] [b 2])
    (next b a))  ; loop forever
  
  ; after
  (nextlet a 1 b 2
    (next b a))

-----