This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-02
Channels
- # announcements (21)
- # babashka (1)
- # beginners (67)
- # calva (18)
- # cider (21)
- # clj-kondo (109)
- # cljs-dev (3)
- # clojure (129)
- # clojure-spec (15)
- # clojure-uk (30)
- # clojurescript (3)
- # datomic (2)
- # graalvm (8)
- # graphql (1)
- # juxt (1)
- # malli (28)
- # off-topic (46)
- # reitit (5)
- # rewrite-clj (33)
- # ring-swagger (2)
- # shadow-cljs (199)
- # vim (9)
Hi all. I am having a tough time understanding "and", "or". For example, why is (and true true) true , (or false false) false, (or false true) false etc
user=> (or false true)
true
user=>
^ not false
. Can you explain what is confusing you?@seancorfield oops sorry, i wrote that from memory
Why true
and true
is true
?
Um, I'm not sure how to answer that... it seems so... obvious to me... so what's your background that such expressions seem weird?
The reason they are defined that way comes out of math/logic: https://en.m.wikipedia.org/wiki/Boolean_algebra
@risinglight ok thanks, i will read up further
OK. Python:
>>> True and True
True
>>> True and False
False
>>> False or False
False
>>> False or True
True
>>>
There's no real reason. It's mathematics. You have to learn it the same way you learn how to count and why 1+1 = 2
I'm just puzzled because it seems the same in Python as Clojure...
@seancorfield yeah i guess i never really understood it there either
Ah, OK. That gives me good context.
The important part is more that it's all combinations of something that can be one of two things.
So the idea is just to have operators that given two things of two possible values, you combine them in different ways. And you want an operator for each possible combination.
Maybe the tables will help:
and | True | False
--------------------
True | True | False
False| False| False
or | True | False
-------------------
True | True | True
False | True | False
` Does that help at all?@seancorfield yes thanks
So if you have one of two things, we can call those possible values 0 and 1 or false and true. And then, if you create the combination you see
1 ? 1 = 1 1 ? 1 = 0 0 ? 0 = 1 0 ? 0 = 0 1 ? 0 = 1 1 ? 0 = 0 Etc. For each of those possible combinations, you want an operator to replace the ?. Or, And, and Not are those operators. And then you have higher level ones that combine those together.
I suspect alarm
would be a symbol and :failure
would be a value, similarly for light
and :red
oh yeah, i just missed the quotes in both "failure" and "red" ...sorry for the confusion
But, given that, yes, that condition could print problem
if both of those conditions were true.
it feels like a huge mountain to climb :S i already got lost in the syntax of multi functions etc
I guess I was lucky that I learned it in high school as an elective, back in the 70's...
My school had a bunch of weird electives... I did Russian and Propositional Calculus and, would you believe, Algol 60 via correspondence...
Some of my friends did Chinese (Mandarin) as an elective. I think Greek was offered too. Can't remember what else.
In college I took a philosophy elective which taught it along with propositional and predicate logic as applied to English.
I think it does help to learn about mathematical logic from a math angle first. Maybe there's some YouTube videos you could watch that are not programming related. Do a few exercise on that first.
A bunch of CS/EE student took it to fulfill an elective requirement, and kind of annoyed the philosophy students by throwing the grading curve off
An interesting combination!
Maybe this https://youtu.be/itrXYg41-V0
Your HS experience sounded kinda awesome @seancorfield
In some ways, yeah. In other ways, it was awful. But it definitely had shades of Harry Potter... four houses, 400 year old stone spiral stairs, big dining hall with masters on the stage and boys on the long benches... and we called everyone by their surname...
(both of those look like good videos @didibus!)
I went to a tiny religious HS that was saving money to buy a new campus instead of spending it on education. I definitely left with some major knowledge gaps...
(in case anyone is curious https://www.collyers.ac.uk/ )
The original school was built in 1540 🙂
The exposure to Algol 60 really did ignite my interest in computing. Algol 68 in university, and Lisp. Then three years researching ML-style FP languages. Nice to get back to it with Clojure in 2010...
Hi all... what site would you recommend for coding exercises for a beginner? I think there are a bunch like koans, exercism etc....i am a novice with little experience
@stoic0 one of the first tutorial I've followed was this-> https://www.youtube.com/watch?v=pIiOgTwjbes and it was really helpful.