Earlier quoted context omitted.
There isn't any problem with this Clojure macro. If you would like to see problems with Clojure, take a look at keep function in core.clj. There is a classic function: (define (filter fn l) (cond ((null? l) '()) ((fn (car l)) (cons (car l) (filter fn (cdr l)))) (else (filter fn (cdr l))))) The point is that stuffing more data-structures into a lisp ruins it. Somehow switching to the prefix notation and adding parenth…
Not sure what the objection to the keep function is, other than maybe the performance optimisations that chunked sequences allow. Taking away the chunked consideration gives something like: (let [x (f (first s))] (if (nil? x) (keep f (rest s)) (cons x (keep f (rest s))))) Which looks almost identical (with differences, as you seem to be giving filter rather than keep, which are different functions). The library funct…
μLithp - a Lisp in 27 lines of Ruby
81–90 of 104 posts
Re: μLithp - a Lisp in 27 lines of Ruby
#82Earlier quoted context omitted.
I've never understood the line-count craze some people get on. If it was that important, we'd all be using J or APL. Since we're not — in fact, almost nobody is — it must not be that critical.
> If it was that important, we'd all be using J or APL. Fallacy. You haven't eliminated the possibility that line count is important, but also that too few lines is also bad. It's widely understood that line count, even though it's a hazy and exploitable metric, is indeed important. It's also widely understood that being too terse is as bad as being too verbose. Time to brush up on some old-school CS curriculum books…
Now, wasn't it more enjoyable the way I put it first?
Re: μLithp - a Lisp in 27 lines of Ruby
#83Really? Lithp? Not that I'm offended, but the pun seems unnecessary.
Re: μLithp - a Lisp in 27 lines of Ruby
#84Re: μLithp - a Lisp in 27 lines of Ruby
#85Earlier quoted context omitted.
Apart from using the JVM, what is the advantage of Clojure over other Lisp dialects?
I am mostly familiar with Clojure as opposed to CL (have read a bit of Practical Common Lisp) or Scheme (have read a decent chunk of SICP), but there are some pieces here and there. Clojure is immutable by default, which is a pretty big difference AIUI. It also has a pretty strong emphasis on concurrency, including a bunch of primitives for such. It uses STM. A bunch of data structures are first class, like vectors,…
Personally I dislike Clojure's syntax - Scheme's feels more pure, cleaner. It's a bit like PERL vs. Python, a matter of taste largely.
Re: μLithp - a Lisp in 27 lines of Ruby
#86related: Norvig's implementation of lisp in python: http://norvig.com/lispy.html
Norvig's implementation of Scheme in Lisp: http://books.google.de/books?id=QzGuHnDhvZIC&lpg=PA756&#...
(book & code) - http://billhails.net/Book/ | Previous HN post - http://news.ycombinator.com/item?id=1747132
Re: μLithp - a Lisp in 27 lines of Ruby
#87Earlier quoted context omitted.
I am mostly familiar with Clojure as opposed to CL (have read a bit of Practical Common Lisp) or Scheme (have read a decent chunk of SICP), but there are some pieces here and there. Clojure is immutable by default, which is a pretty big difference AIUI. It also has a pretty strong emphasis on concurrency, including a bunch of primitives for such. It uses STM. A bunch of data structures are first class, like vectors,…
Clojure is immutable by default what does this sentence mean? How Scheme is less immutable by default? Which data-structures are not first class "objects" in Scheme?
Re: μLithp - a Lisp in 27 lines of Ruby
#88Earlier quoted context omitted.
I am mostly familiar with Clojure as opposed to CL (have read a bit of Practical Common Lisp) or Scheme (have read a decent chunk of SICP), but there are some pieces here and there. Clojure is immutable by default, which is a pretty big difference AIUI. It also has a pretty strong emphasis on concurrency, including a bunch of primitives for such. It uses STM. A bunch of data structures are first class, like vectors,…
Clojure is immutable by default what does this sentence mean? How Scheme is less immutable by default? Which data-structures are not first class "objects" in Scheme?
It may have been misleading to say that Clojure was immutable by default. It is immutable; it does not have set! or the moral equivalent. You can use concurrency primitives to update in place (sort of? AFAICT you're mutating the var itself, not the data it contains) but each primitive comes with its own semantics.
As far as first-class is concerned: in Clojure, maps, sets, and vectors are functions. They're functions of their data as well as being data, and there are literal representations for each.
Examples:
user=> ({:foo 1} :foo) ;; maps are functions
1
user=> (:foo {:foo 1}) ;; keywords are functions, too
1
user=> (filter :name [{:name "foo"} {:surname "baz"}]) ;; filter by key
({:name "foo"})
user=> ([\a \b \c] 2) ;; access vector by index
\c
user=> (#{1 2 3} 4) ;; test set membership
nil
user=> user=> (filter #{2 4 6} (range 1 10)) ;; filter by set membership
(2 4 6)
To what extent is any of that true of Scheme? I am reasonably certain that these data types can't operate as functions in Scheme. Glancing at such as the Racket docs, my impression is that generally you use a specific set of functions to interact with each type (e.g. hash-map-get, hash-has-key?, set-member?).Re: μLithp - a Lisp in 27 lines of Ruby
#89Earlier quoted context omitted.
Clojure is immutable by default what does this sentence mean? How Scheme is less immutable by default? Which data-structures are not first class "objects" in Scheme?
Scheme has set-car!, vector-set!, hash-set! etc to modify its standard containers. In clojure those containers are immutable. However, you could create equivalent immutable containers in Scheme, perhaps that's why he said "by default".
Re: μLithp - a Lisp in 27 lines of Ruby
#90Earlier quoted context omitted.
I am mostly familiar with Clojure as opposed to CL (have read a bit of Practical Common Lisp) or Scheme (have read a decent chunk of SICP), but there are some pieces here and there. Clojure is immutable by default, which is a pretty big difference AIUI. It also has a pretty strong emphasis on concurrency, including a bunch of primitives for such. It uses STM. A bunch of data structures are first class, like vectors,…
Sad (for me) difference: tail call optimization, done automatically in Schemes, unavailable in Clojure. I know of recur and trampoline, but recur does not (I think?) work with mutual recursion and if I wanted to use trampoline, I'd be coding in JavaScript :) Personally I dislike Clojure's syntax - Scheme's feels more pure, cleaner. It's a bit like PERL vs. Python, a matter of taste largely.
I would call it more like Ruby vs. Python — c'mon, perl? that's just mean — but yes, we're quibbling. :)