8 ms·
You don't have to do it like that. You could do: (= (* x (+ y z)) (+ (* x z) (* y z))) Or: (= (* x (+ y z)) (+ (* x z) (* y
by explainplease 8y ago
You don't have to do it like that. You could do:
(= (* x (+ y z))
(+ (* x z) (* y z)))
Or:
(= (* x (+ y z))
(+ (* x z)
(* y z)))
Or:
(= (* x
(+ y z))
(+ (* x z)
(* y z)))
Or:
(= (+ (* x z)
(* y z))
(* x (+ y z)))
Or:
(= (+ (* x z)
(* y z))
(* (+ y z) x))
Or:
(= (+ (* x z)
(* y z))
(* (+ y z)
x))
I think the last one makes the relationships quite clear.
Writing legible equations is an art form, as is writing sexps.
Edit: If you think lisp is ugly, compare with regexps. For bonus points, explore writing regexps with lisp, e.g. with Emacs's `rx` macro. I think you won't find a more easily maintainable way to write them.
- chongli 8y agoSome would argue that the fact that you have all of those alternative forms is part of the problem. Lisp is one of the (if not the) most individualistic programming languages around. Lisp makes it easy for a programmer to create their very own impenetrable, arcane, domain specific languages. This causes large organizations to avoid it like the plague. Large teams don't want artists, they want replaceable parts.
- dorfsmay 8y agoAre you talking about macro or formatting? If it's about formatting, given that this is what this thread is about, you can use code formatter for lisp languages exactly like for any other language, in fact they are even easier to write for lisp because of the consistency of S expressions. If you are talking about macro, then you're in the same boat as other languages that have macros, C, Rust, ect... And remember that the first rule of macros is to not use macros, except for when you absolutely have to, and in those cases it is the most elegant solution. If you have devs inventing DSLs for everything, then lisp isn't your problem.
- explainplease 8y agoSome would argue that Lego and Technic are too complicated, and we should all play with Duplo. Thankfully, Michelangelo and Leonardo were not in large teams. Which do you aspire to be: a cog or an artist?
- chongli 8y agoI think most people would prefer to be an artist, but art rarely pays the bills, hence the cliche "starving artist." My post was not meant to rip on artists, though that's how it comes off now that I read it again. The truth is that society wants more cogs but needs more artists.
- joshuamorton 8y agoIf prefer it if the product of my engineering effort were maintainable and clear. I succeed if someone with no context can understand the system I built without help.
- kazinator 8y agoYou have alternative line breaking in infix also. All of it sucks compared to keeping it on one line, though: x * (y + z) = x * z + y * z x * (y + z) = x * z + y * z x * (y + z) = x * z + y * z x * (y + z) = x * z + y * z etc.
- thibran 8y agoThe tragedy is that the "large organization" then goes on and writes multiple bad DSL to solve problem X which includes several code transpilers and a varying amount of custom syntax. In the end, they do the same thing as the Lisp folks -> they write a DSL, but because language XYZ they chose is less capable than Lisp, the solution is hacky and difficult to understand (and can't be – in comparison to Lisp – easily extended). This is true for a lot of "frameworks" and especially true for modern fontend web frameworks (which have a compile/build step).
- nanaya 8y agoSorry, is it xz + yz = x(y + z) when using operators? That seems wrong.
- quietbritishjim 8y agoI don't know any Lisp, but I would decode (= (* x (+ y z)) (+ (* x z) (* y z))) As x*(y + z) = x*z + y*z e.g. (+ y z) means you add y and z with highest priority.
- zzzcpan 8y agoFor comparison infix notation with the same precedence for all operators: (x * (y + z)) eql ((x * z) + (y * z)) Or: (y + z * x) eql (x * z + (y * z)) With different precedence: x * (y + z) eql x * z + y * z But now you have to remember precedences and mentally regroup the expression.
- wool_gather 8y agoI assume you just copy-pasted from parent, but both of you have written `(* x z)` `(* y z)` rather than `(* x y)` `(* x z)`.