This is Words and Buttons Online — a collection of interactive #tutorials, #demos, and #quizzes about #mathematics, #algorithms and #programming.
Learning a language, you are not going to write in professionally, is like visiting a country you are not going to move in to. It may be tiring, but it’s fun, educational and it makes you appreciate other cultures. And Lisp is particularly fascinating to learn because of its influence on modern programming. You might see traces of Lisp in the most unexpected technologies like WebAssembly or GCC internal representation.
The only reason not to learn Lisp, or any other language, is the amount of effort it usually takes. But! If you only want to know the very basics of Lisp, you wouldn’t have to spend any effort at all.
Since you are reading this article, you probably know English. And this also means that you know a bit of French as well. Words like “concept”, “culture”, “action”, “instinct”, “machine”, “science”, and many more are actually shared between the two languages. Words like these are called “cognates”, and the word “cognate” is almost a cognate itself.
This happens because of long-lasting French influence on the English language. And the same goes for Lisp too. Its ideas and concepts are so widespread among modern languages that if you have any substantial experience in programming at all — you automatically know some Lisp.
I've prepared several exercises so you could prove to yourself that you do know a little Lisp. As many languages and dialects belong to the Lisp family, I should specify that this quiz is based on WeScheme.
The exercises start with very simple things and gradually progress into obscurity. It’s ok not to get all the answers right, some of them would only work for programmers with a functional programming background.
Amuse-toi!
(+ 2 2)
(= (+ 2 2) (* 2 2))
(first (list 'a 'b 'c))
(define apples 5) (define oranges 6) (if (< apples oranges) (printf "Apples") (printf "Oranges"))
(define (dbl x) (* 2 x)) (dbl 2)
(define (fact x) (if (<= x 1) 1 (* x (fact (- x 1))))) (fact 3)
(define (qs xs) (if (empty? xs) (list ) (let ((middle (first xs)) (others (rest xs))) (let ((left (filter (lambda (x) (<= x middle)) others) (right (filter (lambda (x) (> x middle)) others))) (append (qs left) (cons middle (qs right))))))) (qs (list 4 5 1 2 3))
Now it's time to see how well do you know Lisp.
To see your final score, please press the button below.
Index #programming #quizzes | ← there's more. |
+ Github & RSS |