What is a ‘thunk’, as used in Scheme or in general?

It is really simple. When you have some computation, like adding 3 to 5, in your program, then creating a thunk of it means not to calculate it directly, but instead create a function with zero arguments that will calculate it when the actual value is needed. (let ((foo (+ 3 5))) ; the calculation … Read more

How many primitives does it take to build a LISP machine? Ten, seven or five?

Basic Predicates/F-functions McCarthy’s Elementary S-functions and Predicates were: atom Which was necessary because car and cdr are defined for lists only, which means you cannot count on any sort of answer to indicate what was happening if you gave car an atom. eq For testing equality between atoms. car For returning the first half (address) … Read more

Clojure vs other Lisps [closed]

My personal list of reasons for preferring Clojure to other Lisps (p.s. I still think all Lisps are great!): Runs on the JVM – hence gets automatic access to the fantastic engineering in the JVM itself (advanced garbage collection algorithms, HotSpot JIT optimisation etc.) Very good Java interoperability – provides compatibility with the huge range … Read more

What are the actual differences between Scheme and Common Lisp? (Or any other two dialects of Lisp)

This is a bit of a tricky question, since the differences are both technical and (more importantly, in my opinion) cultural. An answer can only ever provide an imprecise, subjective view. This is what I’m going to provide here. For some raw technical details, see the Scheme Wiki. Scheme is a language built on the … Read more

What is the difference between eq?, eqv?, equal?, and = in Scheme?

I’ll answer this question incrementally. Let’s start with the = equivalence predicate. The = predicate is used to check whether two numbers are equal. If you supply it anything else but a number then it will raise an error: (= 2 3) => #f (= 2.5 2.5) => #t (= ‘() ‘()) => error The … Read more

What is “point free” style (in Functional Programming)?

Just look at the Wikipedia article to get your definition: Tacit programming (point-free programming) is a programming paradigm in which a function definition does not include information regarding its arguments, using combinators and function composition […] instead of variables. Haskell example: Conventional (you specify the arguments explicitly): sum (x:xs) = x + (sum xs) sum … Read more

Why does Clojure have “keywords” in addition to “symbols”?

Here’s the Clojure documentation for Keywords and Symbols. Keywords are symbolic identifiers that evaluate to themselves. They provide very fast equality tests… Symbols are identifiers that are normally used to refer to something else. They can be used in program forms to refer to function parameters, let bindings, class names and global vars… Keywords are … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)