Since as long as I've been programming I've wanted a operator that's like the word "or" but not "logical or", rather "please try this OR that if it doesn't work". For ex. in Javascript: `someString.endsWith("jpg" or "png")` Does any programming language do this?
This might be orthogonal, but functional languages' sum types can sort of capture this notion? E,g http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Either.html …
-
-
I've never seen the behavior you're describing but sum types can express the more general idea of "alternate realities": match ending with Jpg => stuff | Png => stuff (* Guaranteed to be either jpg or png *)
-
Ah yeah I see, that is sort of the same idea in a different shape(pattern matching). In the above tweet I was less interested in the general notion of "alternate realities" and more in "having a concise infix notation for trying a function with different values till one succeeds"
- 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.