#reader "rest-reader.ss"
#reader scribble/reader
$module rest-reader-tests scheme

; This also works (instead of the last #reader and $module)
;#lang at-exp scheme

(list 1 $list 1 2 $list 3)
; => (list 1 (list 1 2 (list 3)))
@list[1 $list 1 2 $list 3]
; => (list 1 (list 1 2 (list 3)))
'(1 2 $ 2 3)
; => (quote 1 2 (2 3))

(define (map/values f lst)
  (cond [(empty? lst)  (values empty empty)]
        [else  $let-values ([(a b)    $f $first lst])
               $let-values ([(as bs)  $map/values f $rest lst])
               $values (cons a as) $cons b bs]))

; make sure $ allows a proper amount of line noise
(map/values (λ (x) $values (add1 x) $sub1 x)
            `$ 1 2 ,@$ list $ + 4 5)
; => (2 3 10) (0 10 8)

; make sure the readtable with $ is used at evaluation time
; (also checks that expanding $ works in the REPL)
(read (open-input-string "(list $list)"))
; => (list (list))
(read-syntax #f (open-input-string "(list $list)"))
; => #'(list (list))
