4 ms·
Are fst and snd the standard haskell functions? It doesn't seem worth saving a few characters for how awkward it makes it to read the code, but then again, if w
by dkersten 16y ago
Are fst and snd the standard haskell functions? It doesn't seem worth saving a few characters for how awkward it makes it to read the code, but then again, if we can get used to car, cdr and so on, I guess its not bad. Though in the case of the tutorial, it should definitely state what fst and snd are.
- vito 16y agoThey are standard. There's also `first` and `second`, but they do something different: Prelude> :m + Control.Arrow Prelude Control.Arrow> :t first first :: (Arrow a) => a b c -> a (b, d) (c, d) Prelude Control.Arrow> first (2 +) (1, 4) (3,4) In this case the Arrow instance is just (->), the function type constructor, so you could read that strange type signature as `first :: (b -> c) -> ((b, d) -> (c, d))`. But I've said too much.
- chrisdone 16y agoHey, I will explain fst and snd. In fact I go into them in some detail in later chapters, but I'll mention their use and why they're short at this step too!
- sdp 16y ago...if we can get used to car, cdr and so on, I guess its not bad. Common Lisp (and MzScheme) users can use first (and second, and third...) and rest, and probably should do so when using simple lists.
- dkersten 16y agoMy Lisp of choice is Clojure, which also uses first, second and rest.