Arguments Structures
This library defines arguments structures, values containing a set of positional and keyword argument values. Various utility procedures for constructing and manipulating these structures are provided.
Source code for this library is avaible on Github and is provided under the terms of the MIT License.
procedure
> (arguments 1 2 3 #:foo "bar") (arguments 1 2 3 #:foo "bar")
procedure
(make-arguments positional keyword) → arguments?
positional : list? keyword : keyword-hash?
> (make-arguments '(1 2 3) (hash '#:foo "bar")) (arguments 1 2 3 #:foo "bar")
value
procedure
(arguments-positional arguments) → list?
arguments : arguments?
procedure
(arguments-keyword arguments) → keyword-hash?
arguments : arguments?
procedure
(apply/arguments f args) → any
f : procedure? args : arguments?
> (apply/arguments sort (arguments '("fooooo" "bar" "bazz") < #:key string-length)) '("bar" "bazz" "fooooo")
Added in version 1.1 of package arguments.
Changed in version 1.2.1: caused nondeterministic contract exceptions
procedure
(arguments-merge args ...) → arguments?
args : arguments?
> (arguments-merge (arguments 1 #:foo 2 #:bar 3) (arguments 'a 'b #:foo 'c)) (arguments 1 'a 'b #:bar 3 #:foo 'c)
> (arguments-merge) (arguments)
Added in version 1.3 of package arguments.
syntax
(lambda/arguments args-id body ...+)
> (define pos-sum (lambda/arguments args (apply + (arguments-positional args)))) > (pos-sum 1 2 3) 6
> (pos-sum 1 2 3 #:foo 'bar) 6
Added in version 1.2 of package arguments.
syntax
(define/arguments (id args-id) body ...+)
> (define/arguments (keywords-product args) (for/product ([(k v) (in-hash (arguments-keyword args))]) v)) > (keywords-product #:foo 2 #:bar 3) 6
> (keywords-product 'ignored #:baz 6 #:blah 4) 24
Added in version 1.2 of package arguments.
value
value
> (keyword-hash? (hash '#:foo "bar")) #t
> (keyword-hash? (make-hash '((#:foo . "bar")))) #f
> (keyword-hash? (hash 'foo "bar")) #f