Re: Lisp refactoring puzzle

2011-07-12 Thread Petter Gustad
Xah Lee  writes:

> it's funny, in all these supposedly modern high-level langs, they
> don't provide even simple list manipulation functions such as union,
> intersection, and the like. Not in perl, not in python, not in lisps.

In Common Lisp you have:

CL-USER> (union '(a b c) '(b c d))
(A B C D)
CL-USER> (intersection '(a b c) '(b c d))
(C B)

//Petter
-- 
.sig removed by request. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: merits of Lisp vs Python

2006-12-08 Thread Petter Gustad
Bjoern Schliessmann <[EMAIL PROTECTED]> writes:

> Can you give an example? I cannot imagine how homogenity always
> results in easiness.

CL-USER> (+ 1 2 3 4 5 6 7 8 9 10)
55

CL-USER> (< 1 2 3 4 5 6 7 8 9 10)
T
CL-USER> (< 1 2 3 4 5 6 7 8 9 10 9)
NIL


Petter
-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: merits of Lisp vs Python

2006-12-12 Thread Petter Gustad
Robert Uhl <[EMAIL PROTECTED]> writes:

> that for can understand new objects; CL LOOP is not extensible, unless I
> have missed something big, but it's simple enough to write a
> map-new-object or loop-new-object or whatever).

There is no standard way to extend loop, but most of the major vendors
let you extend it using add-loop-path. In CLSQL you can do stuff like

(loop for (time event) being the tuples of "select time,event from log"
  from *my-db*
  do ... )

Petter
-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-08 Thread Petter Gustad
Xah Lee  writes:

> problem with find xargs is that they spawn grep for each file, which
> becomes too slow to be usable.

find . -maxdepth 2 -name '*.html -print0 | xargs -0 grep whatever

will call grep with a list of filenames given by find, only a single
grep process will run. 

//Petter
-- 
.sig removed by request. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-08 Thread Petter Gustad
Icarus Sparry  writes:

> The 'modern' way to do this is
> find . -maxdepth 2 -name '*.html' -exec grep whatever {} +

Agree, I've noticed that recent version of find have the + option. I
remember in the old days the exec method was considered bad since it
would fork grep for each process, so I've got used to using xargs. I
always used to quote "{}" as well, but this does not seem to be
required in later versions of find.

In terms of the number of forks the above will be similar to xargs as
they both have to make sure that they don't overflow the command
length.


Petter
-- 
.sig removed by request. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-09 Thread Petter Gustad
r...@rpw3.org (Rob Warnock) writes:

> invocation was given only one arg!! IT FOUND THE PATTERN, BUT DIDN'T
> TELL ME WHAT !@^%!$@#@! FILE IT WAS IN!!  :-{

Sounds frustrating, but grep -H will always print the filename, even
when given a single filename on the command line.

//Petter
-- 
.sig removed by request. 
-- 
http://mail.python.org/mailman/listinfo/python-list