Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexknauth/hash-lambda
using hash-tables for rest-arguments that include keyword-arguments
https://github.com/alexknauth/hash-lambda
Last synced: about 1 month ago
JSON representation
using hash-tables for rest-arguments that include keyword-arguments
- Host: GitHub
- URL: https://github.com/alexknauth/hash-lambda
- Owner: AlexKnauth
- License: mit
- Created: 2014-03-26T02:24:29.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2022-07-23T16:37:54.000Z (over 2 years ago)
- Last Synced: 2024-12-02T01:55:01.243Z (about 1 month ago)
- Language: Racket
- Homepage:
- Size: 942 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
hash-lambda
===documentation: http://pkg-build.racket-lang.org/doc/hash-lambda-toc/index.html
hash-lambdas allow you to create a "rest argument" see Declaring a Rest Argument that includes
keyword arguments. Instead of storing the arguments in a list, hash-lambda stores them in a
hash table, where you can use (hash-ref args-hash 0), etc. to access by-position arguments,
and (hash-ref args-hash '#:kw), etc. to access keyword arguments, or you can use
hash-lambda/match and use match patterns for the arguments.
You can also use apply/hash to apply an args-hash to a function.Examples:
```racket
> (require hash-lambda)
> (define my+
(hash-lambda/match
[(hash-table [0 a] [1 b])
(+ a b)]))
> (my+ 1 2)
3
> (define/contract kinetic-energy (#:mass number? #:velocity number? . -> . number?)
(hash-lambda/match
[(hash-table ['#:mass mass] ['#:velocity velocity])
(* 1/2 mass (sqr velocity))]))
> (kinetic-energy #:mass 2 #:velocity 1)
1
```