(and scheme lisp) x Python and modern langs [was Re: gossip, Guy Steel, Lojban, Racket]

cool, is that a pissing contest? I feel an urge:

(pee 1 5 even?)

; given:
(define (pee from to filter?)
  ((range to from) '() (filtered filter? cons)))

(define (filtered filter? reducer)
  (lambda (i o) (if (filter? i) (reducer i o) o)))

(define (range from to . step)
  (let ((> (if (> from to) < >))
        (+ (if (> from to) - +))
        (step (if (null? step) 1 (car step))))
    (lambda (init reducer)
      (let go ((from from) (result init))
        (if (> from to) result
            (go (+ from step) (reducer from result)))))))

plus, by compiling it with, say, chicken, I can get some pretty nice
results for

(p (pee 1 10000 even?))

; given p like ruby's:
(define (p . args) (for-each display args)(newline))

982 9984 9986 9988 9990 9992 9994 9996 9998 10000)

real 0m0.026s
user 0m0.000s
sys 0m0.000s

while with time ruby -e 'p (1..10000).select{|n| n.even? } I get:

972, 9974, 9976, 9978, 9980, 9982, 9984, 9986, 9988, 9990, 9992, 9994,
9996, 9998, 10000]

real 0m0.042s
user 0m0.010s
sys 0m0.000s

···

On 19 out, 01:35, w_a_x_man <w_a_x_...@yahoo.com> wrote:

On Sep 29, 2:55 pm, w_a_x_man <w_a_x_...@yahoo.com> wrote:

> On Sep 24, 2:44 pm, namekuseijin <namekusei...@gmail.com> wrote:

> > Python did good in replacing convoluted syntax, for clearer and more
> > direct equivalent, like:

> > map(lambda x:x+1,[1,2,3,4,5])
> > [x+1 for x in [1,2,3,4,5]]
> > ==> [2,3,4,5,6]

> > List comprehensions also have the added benefit of being an all-in-1
> > replacement for map and filter just nicely:

> > filter(lambda x:x%2==0,[1,2,3,4,5])
> > [x for x in [1,2,3,4,5] if x%2==0]
> > ==> [2,4]

Quite ugly.

> Ruby:

> (1..5).select{|n| 0==n%2}

(1..5).select{|n| n.even?}
==>[2, 4]
(1..5).select( &:even? )
==>[2, 4]