Simulating Machines in Clojure
stopa.io
stopa.io
(< 1 2 3) ;; true
is a lot more intuitive to me than
(> 3 2 1) ;; true
even if one or more of those literals is replaced with an argument. It’s especially apparent with the two-arg use of the function. This is one of the few places where I still feel like infix notation has an advantage.
This isn’t even a nitpick about the article, just a remark about some cognitive dissonance seeing > used here.
(1) Maybe Elements of a Clojure? Not sure that’s it; it was a book referenced on HN which has a whole chapter on naming things.
That's correct.
What should really matter is how you're "talking" in the code. If you've defined some relationship as y being greater than x, then that's how you should phrase the comparison as well: (> y x). (< x y) would be the same thing logically, but we don't read logically: it requires another mental step to understand that (> y x) and (< x y) are equivalent. It's avoiding those extra steps that gives code a really big readability boost.
But "imagine an SR latch!" is always funny to me in these kinds of explanations. The base circuitry for electronics have really powerful primitives, but if you are coming from first principles then it's like.... where did you get this from? In itself it's a really non-intuitive device, and only starts making sense in a larger context.
It's of course also what we actually do, just I think not something anyone would ever come up with in a vacuum if they were thinking "how do I build computers"
You may enjoy this question on SE: https://electronics.stackexchange.com/questions/524618/how-d... -- ended up getting a great answer for how this worked beyond the abstractions I was comfortable with.
Plan on using what I've learned to write something about simulating RAM -- that may get us closer to building up the base circuitry
thank you
Could you really? I've heard of fun things like water-based logic gates, but even with primitive elements like that it doesn't seem at all easy to come up with anything even mildly useful.
Another option would be pulleys: https://www.youtube.com/watch?v=CNbScb8v-MI
https://github.com/nezaj/clj-sicp < here are the answers to the questions we chose to do. Hope it helps in your adventure!