codesnippets:patternmatching
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| codesnippets:patternmatching [2022/10/05 14:21] – external edit | codesnippets:patternmatching [2025/10/08 00:48] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ~~DISCUSSION~~ | ||
| ====== Pattern matching, again ====== | ====== Pattern matching, again ====== | ||
| Line 6: | 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 73: | Line 73: | ||
| main = | main = | ||
| do | do | ||
| - | print (length s) -- " | + | print (length s) |
| s :: String | s :: String | ||
| Line 79: | 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~~ | ||
codesnippets/patternmatching.1664972507.txt.gz · Last modified: (external edit)
