3 ms·
Has it got currying? Partially applied functions passed around in folds and traverses are horribly difficult to read for beginners. Example: an Advent of Code
by Throwaway23459 4y ago
Has it got currying? Partially applied functions passed around in folds and traverses are horribly difficult to read for beginners. Example: an Advent of Code solution posted in r/haskell for Day 10 this year, tell me how long it takes you to understand the function cycleStrengths.
signalStrength cycle x = cycle \* x
cycleGaps = [19, 40, 40, 40, 40, 40]
cycleStrengths = foldr a (const []) cycleGaps . (\x -> (1, x))
where
a n r (i, xs) = signalStrength m y : r (m, ys)
where
m = i + n
ys@(y : _) = drop n xs
From: https://www.reddit.com/r/haskell/comments/zhjg8m/advent_of_code_2022_day_10/ https://www.reddit.com/r/haskell/comments/zhjg8m/advent_of_c...
Personally I love this headscratching stuff, but I would not ever dream of subjecting it upon a beginner programmer.
- justinhj 4y agoThat kind of code is sometimes easier to write than read… you build it up incrementally. On the other hand it’s easy to refactor this to make it readable. Is Haskell supposed to be an easy language for beginners? Is Verse? Not every language should be.
- Throwaway23459 4y ago> [Paraphrasing] Is Verse supposed to be an easy language for beginners ? Yes! Well that was the point of my comment. Maybe you have a different interpretation of 'Learnable as a first language' from the article, which is fine, not interested in arguing about that.
- justinhj 4y agoI guess that part of my comment could have benefited from reading the article, which I have done now. Oops.