this post was submitted on 14 Feb 2024
538 points (96.7% liked)
Programmer Humor
19589 readers
578 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
If your specific use case really needs random access to a list while lazy computing the elements just wrap them in
Lazy
and put them in a vector.The return type of an infinitely recursive function / infinite loops is ⊥, a type that by definition has no values. (Known in rust as
!
)Haskell lets you infinitely recurse while still completing in finite time, and there's even a function (
fix
) for that. Doing e.g.fix (+ 2)
would be an infinite loop if evaluated, yes, butfix (2 :)
would give you a useful value that's an infinite stream of 2s. (it's also useful for other things too)