vault backup: 2025-02-24 20:34:05

This commit is contained in:
Dane Sabo 2025-02-24 20:34:05 -05:00
parent 1896846e77
commit 3c9a5311cd
2 changed files with 19 additions and 1 deletions

View File

@ -119,6 +119,21 @@ take 10 [2, 4..]
-- will only yield even numbers greater than 12 in the first 10 elements of the set
```
I made it to boomBangs and stopped. I'm outta gas :)
boomBangs is an interesting one. We can write code that does a function as the function, while also incorporating predicates.
An easy way to remember: [Function | Set, Predicate, (predicate 2),...]
Fucking Stupid Predicates
We can also use multiple lists. If multiple lists are given (one for each variable), then all combinations of the two lists are used.
Strings are just lists. We can apply list comprehensions to them!
Here's a couple of useful examples:
```haskell
-- Now Writing our own custom list function
length' xs = sum [1 | _ <- xs]
-- use dummy variable _, draw an element from a list and replace it with 1. Sum all of those.
--- Strings are lists! We can use list comprehensions on them.
removeNonUppercase st = [ c | c <- st, c `elem` ['A'..'Z']]
```

View File

@ -18,3 +18,6 @@ schtankyList x = [ x*y | x <- [2,5,10], y <- [8,10,11]]
length' xs = sum [1 | _ <- xs]
-- use dummy variable _, draw an element from a list and replace it with 1. Sum all of those.
--- Strings are lists! We can use list comprehensions on them.
removeNonUppercase st = [ c | c <- st, c `elem` ['A'..'Z']]