Created
August 12, 2015 10:54
-
-
Save jvrdev/0654be7082f1874751bf to your computer and use it in GitHub Desktop.
Proposed solution for kata at http://www.meetup.com/FunctionalKats/events/224121028/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let matches (pattern : string) (x : string) : bool = | |
| let rec matchesL pattern x = | |
| match pattern, x with | |
| | [], [] | ['?'], [] | ['*'], []-> true | |
| | '?'::pTail, xHead::xTail -> matchesL pTail xTail || matchesL pTail x | |
| | '*'::pTail, xHead::xTail -> matchesL pTail xTail || matchesL pTail x || matchesL pattern xTail | |
| | pHead::pTail, xHead::xTail when pHead = xHead -> matchesL pTail xTail | |
| | _ -> false | |
| matchesL (Seq.toList pattern) (Seq.toList x) | |
| let findMatches (pattern : string) (xs : seq<string>) : seq<string> = | |
| Seq.where (matches pattern) xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the equivalent Scala version.