update sugar/list with values->list

pull/2/head
Matthew Butterick 10 years ago
parent 3d3a227ff7
commit 5c1a4dc5fe

@ -70,3 +70,9 @@
(syntax-case stx () (syntax-case stx ()
[(_ test body) [(_ test body)
#'(if test (list body) '())])) #'(if test (list body) '())]))
(provide values->list)
(define-syntax (values->list stx)
(syntax-case stx ()
[(_ values-expr) #'(call-with-values (λ () values-expr) list)]))

@ -9,8 +9,7 @@
"list.rkt" "list.rkt"
"misc.rkt" "misc.rkt"
"string.rkt" "string.rkt"
"len.rkt" "len.rkt")
"values.rkt")
(provide (provide
(all-from-out (all-from-out
@ -22,5 +21,4 @@
"list.rkt" "list.rkt"
"misc.rkt" "misc.rkt"
"string.rkt" "string.rkt"
"len.rkt" "len.rkt"))
"values.rkt"))

@ -3,7 +3,7 @@
@(require scribble/eval (for-label racket sugar)) @(require scribble/eval (for-label racket sugar))
@(define my-eval (make-base-eval)) @(define my-eval (make-base-eval))
@(my-eval `(require sugar)) @(my-eval `(require sugar racket/list))
@title{List} @title{List}
@defmodule[sugar/list] @defmodule[sugar/list]
@ -82,3 +82,11 @@ A special version of @racket[when] that you can use inside @racket[quasiquote] t
`(,@(when/splice (even? 2) "hooray")) `(,@(when/splice (even? 2) "hooray"))
`(,@(when/splice (even? 3) "hooray")) `(,@(when/splice (even? 3) "hooray"))
] ]
@defform[(values->list values)]
Convert @racket[_values] to a simple list.
@examples[#:eval my-eval
(split-at '(a b c d e f) 3)
(values->list (split-at '(a b c d e f) 3))
]

@ -1,13 +0,0 @@
#lang racket/base
(require (for-syntax racket/base))
(provide (all-defined-out))
(define-syntax (values->list stx)
(syntax-case stx ()
[(_ values-expr) #'(call-with-values (λ () values-expr) list)]))
(define-syntax (apply-values stx)
(syntax-case stx ()
[(_ proc values) #'(apply proc (values->list values))]))
Loading…
Cancel
Save