4 ms·
Oh! So `go` is a function that's defined within `shift`. That's the crucial part I was missing. Why is it named "go"? EDIT: While I have your attention, do you
by jabagawee 12y ago
Oh! So `go` is a function that's defined within `shift`. That's the crucial part I was missing. Why is it named "go"?
EDIT: While I have your attention, do you mind also pointing me to some resources to learn about this ">>=" operator? I recall it's something related to monads...
- taylorfausak 12y agoAs ibotty said, I named the anonymous inner worker function `go`. From what I can tell, it seems to be pretty common in Haskell. As for `>>=` (also known as `bind`), I'm using it as a more generic version of `concatMap`. The following expressions are basically the same: concat (map (\ x -> [x, -x]) [1, 2, 3]) concatMap (\ x -> [x, -x]) [1, 2, 3] [1, 2, 3] >>= \ x -> [x, -x] If you want to learn more, check out LYAH [1]. [1]: http://learnyouahaskell.com/a-fistful-of-monads http://learnyouahaskell.com/a-fistful-of-monads
- gu 12y agoThe bind operator (>>=) is commonly expressed in 'do' notation. The following two code snippets are equivalent: do x <- foo; y <- bar; baz x y foo >>= \x -> bar >>= \y -> baz x y
- ibotty 12y ago`go` is a very old name for worker functions in haskell. i have been told it originates in glasgow (where ghc was first developed).