codesnippets:patternmatching
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| codesnippets:patternmatching [2024/06/02 22:09] – f2b216 | codesnippets:patternmatching [2025/10/08 00:48] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| * list comprehensions | * list comprehensions | ||
| * do notations | * do notations | ||
| + | * case constructs | ||
| Before we start with that, we provide more details about pattern matching, regarding: | Before we start with that, we provide more details about pattern matching, regarding: | ||
| Line 72: | Line 73: | ||
| main = | main = | ||
| do | do | ||
| - | print (length s) -- " | + | print (length s) |
| s :: String | s :: String | ||
| Line 78: | Line 79: | ||
| length :: [a] -> Integer | length :: [a] -> Integer | ||
| - | length [] = 0 | + | length [] = 0 -- "inner function perspective" |
| - | length (_:lrx) = 1 + (length lrx) | + | length (_:lrx) = 1 + (length lrx) -- "inner function perspective" |
| - | -- using the rest (lrx) for recursive call of length (again " | + | |
| + | </ | ||
| ===== ✎ ===== | ===== ✎ ===== | ||
| ~~DISCUSSION~~ | ~~DISCUSSION~~ | ||
codesnippets/patternmatching.1717358942.txt.gz · Last modified: (external edit)
