Why does this Haskell code work successfully with infinite lists?

Let’s do a little trace in our heads of how Haskell will evaluate your expression. Substituting equals for equals on each line, the expression pretty quickly evaluates to True: myAny even [1..] foldr step False [1..] step 1 (foldr step False [2..]) even 1 || (foldr step False [2..]) False || (foldr step False [2..]) … Read more

Collapsible header in Markdown to html

Try: <details> <summary>Your header here! (Click to expand)</summary> Your content here… > markup like blockquote’s should even work on github! more content here… </details> You can try this sort of thing here: <details> <summary>Your header here! (Click to expand)</summary> Your content here…</br> (markup only where supported)</br> more content here…</br> </details> This works for me with … Read more

Scala : fold vs foldLeft

The method fold (originally added for parallel computation) is less powerful than foldLeft in terms of types it can be applied to. Its signature is: def fold[A1 >: A](z: A1)(op: (A1, A1) => A1): A1 This means that the type over which the folding is done has to be a supertype of the collection element … Read more

tech