In the MAD example the letter O has a slash through it, and the numeral zero is unslashed. Does anyone know if this was an actual printing convention at one time? It seems backwards from how it's done today.
If-then-else had to be invented
241–250 of 255 posts
Re: If-then-else had to be invented
#242Recognised that GitHub username straight away. That author also made "datamaps": https://github.com/ericfischer/datamaps I remember over 5 years ago, they helped me me visualise 1 billion "Shazam's" (where I was working at the time) onto map tiles. Glad to see they are still supporting developers!
Re: If-then-else had to be invented
#243Just one of those things that no one really questions the existence of. It, like the semicolon, always has been and will be. Good work digging through these historic esoteric languages. Wikipedia states McCarthy of Lisp fame invented it so many of the evangelists here likely know the conclusion here.
“It, like the semicolon, always has been and will be.” Not the best of examples. It hasn’t always been. Early fortran and lisp didn’t have it. Reading https://medium.com/better-programming/a-brief-history-of-the... , it seems Algol and PL/I set the trend to make it popular. Looking at newer languages, I also get the impression it’s on the way out. Rust has them, but python, scala, go and swift try to avoid them ( htt…
Re: If-then-else had to be invented
#244I remember there was a paper that tried to compare natural language usage of common programming language keywords to see if they may come up with other constructs to create a programming language that is easier to learn as your first one. There were a few interesting observations. The one that stuck with me the most is that 'and' is most commonly used with almost the opposite sense in natural language vs programming:…
"we usually describe operations on sets as taking the whole set as an argument, not in terms of what happens with each individual member" Doesn't R do it like that too?
Re: If-then-else had to be invented
#245Earlier quoted context omitted.
ah but it's more complicated because only the main verb is at the end of the sentence, so if you need an auxiliary or you have a copular construction like "ist gleich", you need to split the verb phrase... in fact, Germans would say (and do say, e.g. in mathematics) "wenn a gleich b" as a shorthand for "wenn a gleich b ist".
Interesting. Seems sorta like the English shorthand "if a less-than b, do this" (as opposed to "if a IS less than b, do this"). "Equal" is almost a different story since it works as a verb as well as an adjective.
Re: If-then-else had to be invented
#246Earlier quoted context omitted.
"if then else" is indicative of an underlying pattern that exists at a more fundamental level. In that sense, it was "discovered", not invented. Depending on the language, the syntax of "if then else" is not needed and is syntactic sugar. In the Lambda Calculus you can implement "if else" using "first" and "second". Here is something equivalent in JavaScript. const trueFn = (first, second) => first const falseFn = (f…
Not truly equivalent! let's define `delete(file)`, which returns 0 if it successfully deletes the file, and 1 if there's an error. ifFn(trueFn, delete('A'), delete('B')) will not do what you want it to.
Re: If-then-else had to be invented
#247Earlier quoted context omitted.
In regards to global vs local optimum it is useful to look at the alternatives like pattern matching. For languages that don't support pattern matching or passing in functions as values, "if" is probably the best you can do with. You might be able to do something with boolean short-circuit operators but it's debatable if that that is better than the if statement. In React, if you are using JSX, they don't have "if" s…
> Also, "if / else" only supports 2 cases, with pattern matching you can have an arbitrary amount of cases. Coming from a non-pattern marching language (python) I’ve yet to see what the big deal is, maybe you can help. I can have as many elif’s as I need cases and other than maybe not needing to repeat `x==...` I’m not sure what I’m missing out on. With that being said, I do often wish for more elegant solutions to l…
It is true that you can always just use if statements, it's more about the convenience and cleaner syntax. You can also do destructuring with pattern matching. Pattern matching is almost a requirement if you are going to use algebraic data types.
As Paul Graham says in Beating the Averages, you have to look at the other language from the perspective of knowing it. Nobody can really explain it. It's just going to seem equivalent or weird syntax otherwise.
Re: If-then-else had to be invented
#248Earlier quoted context omitted.
They are equivalent (assuming ^ is the same as &). In particular, A --> B is equivalent to ¬A | B.
I see. I interpreted `^` as XOR. The implication (`-->`) was clear enough to not be misunderstood.
Re: If-then-else had to be invented
#249Earlier quoted context omitted.
I lean toward "if a b c" being a true primitive, due to it being one of the special forms in Lisp. This is necessary to avoid evaluating the arguments in the road-not-taken, without fexprs, and I daresay that would be a distraction at the moment. It's also embodied in actual machine words. The actual verbiage of "if a then b else c" is clearly less important, C elides the "then" after all. I'm presuming you mean the…
The historical truth is that Lisp had COND first; IF was added later. Also, LAMBDA before LET. MacCarthy writes, in History of Lisp : I invented conditional expressions in connection with a set of chess legal move routines I wrotein FORTRAN for the IBM704 at M.I.T. during1957-58. This program did not use list processing. The IF statement provided in FORTRAN1 and FORTRAN2 was very awkward to use, and it was natural to…
It's not uncommon at all in mathematics to build a system with certain axioms, and then improve them later, when it's realized that simpler axioms can be used to build more complex constructs.
Re: If-then-else had to be invented
#250Earlier quoted context omitted.
I see. I interpreted `^` as XOR. The implication (`-->`) was clear enough to not be misunderstood.
The "ʌ" symbol (^ due to laziness) is commonly used to mean AND in propositional/formal logic in mathematics: https://en.wikipedia.org/wiki/Propositional_calculus