Why Operators Are Useful
neopythonic.blogspot.com
Why Operators Are Useful
1–10 of 173 posts
Re: Why Operators Are Useful
#2This is a non-problem if you're using Lisp. (+ x y z) accepts an arbitary number of arguments and the operator precedence problem does not exist since there is no operator precedence.
Re: Why Operators Are Useful
#3This is much less confusing than (2), and leads to the observation that the parentheses are redundant, so now we can write "x + y + z" This is a non-problem if you're using Lisp. (+ x y z) accepts an arbitary number of arguments and the operator precedence problem does not exist since there is no operator precedence.
Re: Why Operators Are Useful
#4This is much less confusing than (2), and leads to the observation that the parentheses are redundant, so now we can write "x + y + z" This is a non-problem if you're using Lisp. (+ x y z) accepts an arbitary number of arguments and the operator precedence problem does not exist since there is no operator precedence.
(eql (* x (+ y z)) (+ (* x y) (* x z)))
I wonder if its famed sense of enlightenment is partly just overcoming the mental hurdle of it's syntax.Edit: typo fix, had x/z mixed up
Re: Why Operators Are Useful
#5This is much less confusing than (2), and leads to the observation that the parentheses are redundant, so now we can write "x + y + z" This is a non-problem if you're using Lisp. (+ x y z) accepts an arbitary number of arguments and the operator precedence problem does not exist since there is no operator precedence.
Re: Why Operators Are Useful
#6This is much less confusing than (2), and leads to the observation that the parentheses are redundant, so now we can write "x + y + z" This is a non-problem if you're using Lisp. (+ x y z) accepts an arbitary number of arguments and the operator precedence problem does not exist since there is no operator precedence.
Lisp is pretty ugly :) (eql (* x (+ y z)) (+ (* x y) (* x z))) I wonder if its famed sense of enlightenment is partly just overcoming the mental hurdle of it's syntax. Edit: typo fix, had x/z mixed up
(= (* 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.
Re: Why Operators Are Useful
#7Earlier quoted context omitted.
Lisp is pretty ugly :) (eql (* x (+ y z)) (+ (* x y) (* x z))) I wonder if its famed sense of enlightenment is partly just overcoming the mental hurdle of it's syntax. Edit: typo fix, had x/z mixed up
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. Ed…
Large teams don't want artists, they want replaceable parts.
Re: Why Operators Are Useful
#8Re: Why Operators Are Useful
#9Earlier quoted context omitted.
Lisp is pretty ugly :) (eql (* x (+ y z)) (+ (* x y) (* x z))) I wonder if its famed sense of enlightenment is partly just overcoming the mental hurdle of it's syntax. Edit: typo fix, had x/z mixed up
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. Ed…
xz + yz = x(y + z)
when using operators?
That seems wrong.
Re: Why Operators Are Useful
#10Earlier quoted context omitted.
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. Ed…
Sorry, is it xz + yz = x(y + z) when using operators? That seems wrong.
(= (* 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.