https://github.com/tmccombs/optima.hash-pattern
Optima patterns for hash-tables
https://github.com/tmccombs/optima.hash-pattern
Last synced: 6 months ago
JSON representation
Optima patterns for hash-tables
- Host: GitHub
- URL: https://github.com/tmccombs/optima.hash-pattern
- Owner: tmccombs
- Created: 2015-01-03T06:16:37.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-03T06:21:00.000Z (over 11 years ago)
- Last Synced: 2025-01-26T00:12:00.264Z (over 1 year ago)
- Language: Common Lisp
- Size: 113 KB
- Stars: 6
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
optima.hash-pattern - Hash Table Patterns for Optima
====================================================
optima.hash-pattern is an extension to [Optima](https://github.com/m2ym/optima)
that supplies some patterns to match against
common lisp hash-tables. There is one constructor pattern, and one
dervied pattern.
hash-property
-------------
The `hash-property` pattern is similar to the `property` pattern,
but matches against a hash-table rather than a plist.
### Syntax:
(hash-property KEY PATTERN)
### Examples:
(let ((tab (make-hashtable)))
(setf (gethash :a tab) 1)
(match tab
((hash-property :a x) x)))
=> 1
hashtable
---------
The `hashtable` pattern is similar to the `plist` pattern,
but matches agains a hash-table rather than a plist
### Syntax:
(hashtable {KEY PATTERN}*)
### Expansion:
(hashtable {k p}* => (and (hash-property k p)*)
### Example:
(let ((tab (make-hashtable)))
(setf (gethash :name tab) \"John\")
(setf (gethash :age tab) 23)
(match tab
((hashtable :name \"John\" :age age) age)))
=> 23