Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexknauth/match-string
string-append and append as a match patterns
https://github.com/alexknauth/match-string
Last synced: about 1 month ago
JSON representation
string-append and append as a match patterns
- Host: GitHub
- URL: https://github.com/alexknauth/match-string
- Owner: AlexKnauth
- License: mit
- Created: 2014-08-11T23:39:22.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-06-25T18:36:22.000Z (over 3 years ago)
- Last Synced: 2024-10-16T02:55:02.684Z (3 months ago)
- Language: Racket
- Homepage:
- Size: 35.2 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
match-string [![Build Status](https://travis-ci.org/AlexKnauth/match-string.png?branch=master)](https://travis-ci.org/AlexKnauth/match-string)
===
string-append and append as a match patternsdocumentation: http://pkg-build.racket-lang.org/doc/match-string/index.html
Examples:
```racket
> string-append
#
> (string-append "abc" "def")
"abcdef"
> (match "abcdef"
[(string-append "abc" s) s])
"def"
> (match "ab cdef"
[(string-append (or "abc" "ab c") s) s])
"def"
> (match "cadaddadddr"
[(string-append "c" (and x (or "a" "d")) ... "r")
x])
'("a" "d" "a" "d" "d" "a" "d" "d" "d")
> (match "abababab"
[(string-append (and los (or "ab" "abab")) ..3)
los])
'("abab" "ab" "ab")
> (match "abababab"
[(string-append (string-append (and lol "ab") ...+) ..3)
lol])
'(("ab" "ab") ("ab") ("ab"))
> (match (list 1 2 3 4 5 6)
[(append (list 1 2 3) p) p])
'(4 5 6)
> (match '(1 2 3 . 4)
[(append (list 1 2) p) p])
'(3 . 4)
> (match '(1 2 3 . 4)
[(append (list 1 2 3) p) p])
4
> (match '(0 1 #:kw-1 kw-arg-1 2 #:kw-2 kw-arg-2 3 4)
[(append (and lol (or (list (? keyword?) _) (list (not (? keyword?))))) ...)
lol])
'((0) (1) (#:kw-1 kw-arg-1) (2) (#:kw-2 kw-arg-2) (3) (4))
> (match '(a b a b a b a b)
[(append (append (and lolol '(a b)) ...+) ..3)
lolol])
'(((a b) (a b)) ((a b)) ((a b)))
> (match '(1 2 3 . 4)
[(append (and l (or '(1) '(2) '(3) 4)) ..4) l])
'((1) (2) (3) 4)
```