Hi All,
MJD, a well known Perl hacker, has written a new Perl book
named "Higher Order Perl". In this book, he takes on a path
that basically teaches one to think Lispily while writing
Perl. Here is an interview with him that you may find interesting:
http://www.theperlreview.com/Interviews/mjd-hop-20050407.html?up
Some notable quotes:
* I said that Perl shares six of Norvig's "seven features that make
Lisp Different".
* "Source filters always break." And I think that's true. But source
filters in Lisp are easy to write, and they never break
* I don't think Lisp is a good example of a functional language and I
don't think most Lisp programmers would consider it one. "Functional
language" suggests a firm philosophical stance against side effects.
* If you're going to learn a new language, Common Lisp would be a good
choice. So would Haskell.
* But I find Haskell and SML more attractive, for various reasons. One
is that the Lisp user community is severely dysfunctional. Another is
that I find the strong typing of Haskell and SML fascinating.
The last bullet may be a bit controvetsial for this list, but it's not
pure flame. While I'm not sure about the dysfunctionality of the Lisp
community because I haven't been around for anough time, one can't
deny that the Perl community is an astonishing phenomenon,
unprecedented
in the history of online communities. Websites like perlmonks.org and
CPAN
are alone worth gold, so I'm not surprised Perl people have criticisms
towards
other communities for their relative "dysfunction".
Eli
Eli Bendersky wrote:
> * If you're going to learn a new language, Common Lisp would be a good
> choice. So would Haskell.
What about reading about (and maybe doing some) Haskell and
learning Lisp?
> * But I find Haskell and SML more attractive, for various reasons. One
> is that the Lisp user community is severely dysfunctional. Another is
> that I find the strong typing of Haskell and SML fascinating.
I don't think the Lisp community is bad at all, but I haven't been
here long.
I share your love of static typing, but right now the great syntax
of Lisp (and macros!) and all its procedural and control flow
features look so freaking powerful that I think it makes for a
much more pragmatic choice (I used some SML before). Plus I can
always write my own statically typed pseudo-lisp frontend with
macros ;)
--
No man is good enough to govern another man without that other's
consent. -- Abraham Lincoln
On 15 Apr 2005 00:48:30 -0700, <······@gmail.com> wrote:
>
> The last bullet may be a bit controvetsial for this list, but it's not
> pure flame. While I'm not sure about the dysfunctionality of the Lisp
> community because I haven't been around for anough time, one can't
> deny that the Perl community is an astonishing phenomenon,
> unprecedented in the history of online communities. Websites like
> perlmonks.org and CPAN are alone worth gold, so I'm not surprised
> Perl people have criticisms towards other communities for their
> relative "dysfunction".
Indeed. One of the hardest things for me to accept when I switched
from perl to the "right way" was the total absence of anything
approaching CPAN in the older language. When I started my project in
perl some time ago, I had code running in about 30 minutes, since I
could grab a dozen packages off of CPAN, shove them together and go.
In CL, packages exist for the datastore and maybe some of the front
end, everything else I need to create (but at least I have a roadmap).
I suspect that CL will never get anywhere close to CPAN, Lispers just
have so much power to do things their own way (down to the dotting of
i) that strong herd groups will simply never happen. It is the kind
of thinking that made single user Lisp Machines (whereas even Windows
3.1 had some token attempt at multiuser). I like it.
--
Everyman has three hearts;
one to show the world, one to show friends, and one only he knows.
On Sat, 16 Apr 2005 03:12:05 -0700, GP lisper
<········@CloudDancer.com> wrote:
>On 15 Apr 2005 00:48:30 -0700, <······@gmail.com> wrote:
>>
>> The last bullet may be a bit controvetsial for this list, but it's not
>> pure flame. While I'm not sure about the dysfunctionality of the Lisp
>> community because I haven't been around for anough time, one can't
>> deny that the Perl community is an astonishing phenomenon,
>> unprecedented in the history of online communities. Websites like
>> perlmonks.org and CPAN are alone worth gold, so I'm not surprised
>> Perl people have criticisms towards other communities for their
>> relative "dysfunction".
>
>Indeed. One of the hardest things for me to accept when I switched
>from perl to the "right way" was the total absence of anything
>approaching CPAN in the older language. When I started my project in
>perl some time ago, I had code running in about 30 minutes, since I
>could grab a dozen packages off of CPAN, shove them together and go.
>In CL, packages exist for the datastore and maybe some of the front
>end, everything else I need to create (but at least I have a roadmap).
>
>I suspect that CL will never get anywhere close to CPAN, Lispers just
>have so much power to do things their own way (down to the dotting of
>i) that strong herd groups will simply never happen. It is the kind
>of thinking that made single user Lisp Machines (whereas even Windows
>3.1 had some token attempt at multiuser). I like it.
Well... There was a long thread some time ago around the issue that
"Lisp need libraries". People supporting this view were labeled as
"trolls", "idoits" and "shit eaters", just to stay with more polite
epitets.
You should know: LISP IS BETTER AND DOES'T NEED CPAN!
A.L.
On Sat, 16 Apr 2005 07:23:56 -0500, <·················@hotfuck.com> wrote:
>
>
> On Sat, 16 Apr 2005 03:12:05 -0700, GP lisper
>><········@CloudDancer.com> wrote:
>>
>>I suspect that CL will never get anywhere close to CPAN, Lispers just
>>have so much power to do things their own way (down to the dotting of
>>i) that strong herd groups will simply never happen. It is the kind
>>of thinking that made single user Lisp Machines (whereas even Windows
>>3.1 had some token attempt at multiuser). I like it.
>
> You should know: LISP IS BETTER AND DOES'T NEED CPAN!
You should read the last sentence more carefully.
--
Everyman has three hearts;
one to show the world, one to show friends, and one only he knows.
A.L. wrote:
> Well... There was a long thread some time ago around the issue that
> "Lisp need libraries". People supporting this view were labeled as
> "trolls", "idoits" and "shit eaters", just to stay with more polite
> epitets.
>
> You should know: LISP IS BETTER AND DOES'T NEED CPAN!
Could you refer to that thread so that people can check whether your
characterization of things is accurate?
Thanks,
Pascal
--
2nd European Lisp and Scheme Workshop
July 26 - Glasgow, Scotland - co-located with ECOOP 2005
http://lisp-ecoop05.bknr.net/
On Sat, 16 Apr 2005 14:40:04 +0200, Pascal Costanza <··@p-cos.net>
wrote:
>A.L. wrote:
>
>> Well... There was a long thread some time ago around the issue that
>> "Lisp need libraries". People supporting this view were labeled as
>> "trolls", "idoits" and "shit eaters", just to stay with more polite
>> epitets.
>>
>> You should know: LISP IS BETTER AND DOES'T NEED CPAN!
>
>Could you refer to that thread so that people can check whether your
>characterization of things is accurate?
>
>
Sorry, I don't keep usenet discussions longer than 2 weeks,
therefore I have no trace. If you can wait a week, the I will do the
search. I am driving to teh airport in about 2 hours and have to
pack...
A.L.
From: Edi Weitz
Subject: Re: "Higher Order Perl" book and Lisp
Date:
Message-ID: <uy8bi3gfv.fsf@agharta.de>
On Sat, 16 Apr 2005 07:23:56 -0500, A.L. <·················@hotfuck.com> wrote:
> Well... There was a long thread some time ago around the issue that
> "Lisp need libraries". People supporting this view were labeled as
> "trolls", "idoits" and "shit eaters", just to stay with more polite
> epitets.
<http://groups-beta.google.com/groups?q=group%3Acomp.lang.lisp+shit+eater&qt_s=Search>
Looks like you either made something up or confused c.l.l with the way
/you/ usually communicate with other people.
--
Lisp is not dead, it just smells funny.
Real email: (replace (subseq ·········@agharta.de" 5) "edi")
GP lisper wrote:
> When I started
> my project in perl some time ago, I had code running in
> about 30 minutes, since I could grab a dozen packages
> off of CPAN, shove them together and go. In CL, packages
> exist for the datastore and maybe some of the front end,
> everything else I need to create (but at least I have a
> roadmap).
This has been my experience with Perl. It's inelegant,
indeed ugly, ugly, ugly -- but extremely practical for
_my_ purposes. My last web app required an ftp client,
an HTML parser, a CGI interface, a templating system, and
a lot of data mining using regular expressions. All
_could_ have been done more elegantly using a Lisp object
system, but I needed my app _fast_ and the Perl tools
were easy to find. I don't think of Perl so much as a
language as I think of it as a really nice set of
completed tools that are easy to find and link together.
···@zedat.fu-berlin.de (Stefan Ram) writes:
> for(0..100){s/5/++$i/ge;}print $i;
Using the substitution operator when the match operator would suffice
is distasteful. Of course, you'd need to test the match or use
index(), perhaps multiple times, which may not be to your taste.
--
Steven E. Harris
<···@zedat.fu-berlin.de> wrote:
> (loop for i from 0 to 100 with c = 0 finally (return c) do
> (loop for d across (format nil "~A" i) do (when (char= d #\5) (incf c))))
How about:
(loop for i from 0 to 100 sum (count #\5 (princ-to-string i)))
--
Juho Snellman
"Premature profiling is the root of all evil."
Juho Snellman wrote:
> <···@zedat.fu-berlin.de> wrote:
>
>>(loop for i from 0 to 100 with c = 0 finally (return c) do
>> (loop for d across (format nil "~A" i) do (when (char= d #\5) (incf c))))
>
>
> How about:
>
> (loop for i from 0 to 100 sum (count #\5 (princ-to-string i)))
>
(count #\5 (format nil "~{~A~}" (loop for i to 100 collect i)))
Paul
Juho Snellman <······@iki.fi> wrote:
> (loop for i from 0 to 100 sum (count #\5 (princ-to-string i)))
yes, that's better. Looks like I have still to learn a lot.
Another solution:
(reduce #'+ (mapcar #'(lambda (i) (count #\5 (princ-to-string i)))
(loop for i from 0 to 100 collect i)))
If Lisp had currying and a function composing operator, it would be as
short as in Haskell.
But the shortest solution is in J (http://www.jsoftware.com/), an APL-
like language:
+/'5'E.":i.100
I'm still a J beginner, so it might be possible that it could be written
shorter. You need some time to understand the language, but then you can
write programs in it, but for me it looks a bit like a one-way language
(like Perl): it is easy to write J programs, but some time later it will
be difficult to read and understand it again.
--
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Frank Buss wrote:
> (like Perl): it is easy to write J programs, but some time later it will
> be difficult to read and understand it again.
Not if you add a few comments don't try to cram too much into one line.
I don't use J but I have been using APL since 1967. Needless to say,
I have gone through a fair number of different implementations. I am
still using some functions I wrote back then. Often they have been
modified several times to take advantage of new ande better things such
as nested arrays and complex numbers.
Aa hint: Make your comments say _what_ you want to accomplish not _how_
you accomplish it. The code does a far better job of the latter. e.g.
{del} z{is}D_S_T yr;M;DTS;D;dt;{quad}IO
[1] {rem} E*2 041213 Start and end of Daylight saving time in year, yr
[2] {quad}IO{is}1 {diamond} 'Daysof Day' need 'date'
[3] dt{is}400 1000+10000{times}yr {rem} Apr and Oct as yymm00
[4] D{is}0=0 Day{each}{each}DTS{is}Daysof{each}dt {rem} Dates and
which are Sundays
[5] z{is}(<\{take}D)/{take}DTS {rem} DST start date
[6] z{is}0.02+z,({rot}<\{rot}2{disclose}D)/2{disclose}DTS {rem} DST
starts/ends
{del}
The conversion to ASCII doesn't help but you get the idea.
Ted
From: Christopher C. Stacy
Subject: Re: "Higher Order Perl" book and Lisp
Date:
Message-ID: <uwtr22z61.fsf@news.dtpq.com>
Frank Buss <··@frank-buss.de> writes:
> I'm still a J beginner, so it might be possible that it could be written
> shorter. You need some time to understand the language, but then you can
> write programs in it, but for me it looks a bit like a one-way language
Don't know J, but my experience with APL (from the 1970s,
a few years before I started programming in Lisp)
is that it is perfectly readable in the long run.
Christopher C. Stacy wrote:
> Don't know J, but my experience with APL (from the 1970s,
> a few years before I started programming in Lisp)
> is that it is perfectly readable in the long run.
And almost certainly more readable than a C equivalent
program for almost anything with some complexity. With APL
you see the cake, not the cookbook.
Bob
--
"Things should be described as simply as possible, but no
simpler."
A. Einstein
Bob Cain wrote:
> And almost certainly more readable than a C equivalent program for
> almost anything with some complexity.
With APL you see the cake, not the cookbook.
I like that! Mind if I steal it?
I have programmed in several languages and find APL the easiest to read
- either to upgrade my own stuff or when I'm given some functions.
Ted
Ted Edwards wrote:
> Bob Cain wrote:
>
>> And almost certainly more readable than a C equivalent program for
>> almost anything with some complexity.
>
>
> With APL you see the cake, not the cookbook.
>
> I like that! Mind if I steal it?
Sure. It's not original with me, however. I read it in
something in the late '60s or early '70s while learning APL
from Luther Woodrum. No real idea where I saw it, though.
FWIW, my favorite saying of Luther's was, "Exploit
serendipity." :-)
Bob
--
"Things should be described as simply as possible, but no
simpler."
A. Einstein
······@news.dtpq.com (Christopher C. Stacy) wrote:
> Don't know J, but my experience with APL (from the 1970s,
> a few years before I started programming in Lisp)
> is that it is perfectly readable in the long run.
you are right. You have to learn the meaning of all the single or two
char commands first, but the language itself is much easier than Perl.
Looks like J has a powerful set of commands. Perhaps it could be
translated to Lisp? Of course, this should be done the Lisp-way, which
means using verbose names:
(defun sum (list)
(reduce #'+ list))
(defun seq-eql (element list)
(map 'list #'(lambda (x) (if (eql element x) 1 0)) list))
(defun make-seq (last)
(loop for i from 0 below last collect i))
The translation of this J expression: +/'5'=":i.100 :
(sum (list-eql #\5 (princ-to-string (make-seq 100))))
But it could be done nearly as short as in J:
(defun +/ (list)
(reduce #'+ list))
(defun j= (element list)
(map 'list #'(lambda (x) (if (eql element x) 1 0)) list))
(defun i. (last)
(loop for i from 0 below last collect i))
(defun \"\: (object)
(princ-to-string object))
(sum (list-eql #\5 (princ-to-string (make-seq 100))))
(+/ (j= #\5 (\"\: (i. 100))))
But using \"\: is not very readable. What about writing some macros (and
perhaps reader-macros) for embedding J into Lisp? I don't have enough
time now to do it, but looks promising.
--
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Frank Buss wrote:
> The translation of this J expression: +/'5'=":i.100 :
>
> (sum (list-eql #\5 (princ-to-string (make-seq 100))))
>
> But it could be done nearly as short as in J:
+/'5'=":i.100
20
sum=:+/
what=:'5'
equal=:=
format=:":
numbers=:i.100
sum what equal format numbers
20
"Bj�rn Helgason" <······@gmail.com> wrote:
> +/'5'=":i.100
> 20
>
> sum=:+/
>
> what=:'5'
>
> equal=:=
>
> format=:":
>
> numbers=:i.100
>
> sum what equal format numbers
> 20
thanks. First I thought "sum:=+/" is an explanation, but this is all J,
too, and the last line, "sum what equal format numbers", is perfectly
valid J!
--
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
You can write everything with words in J if you fancy
You could create LISP in J if that is your preference
You can also program with do, if and all that if you want
(see J for C Programmer that comes with J)
The words and the do's get compiled into primitives
Using the primitives directly is for some like going step further and
is in a way like writing the binary you would otherwise get frome the
compiled words
One of the biggest difference between J and old APLs is the use of
ordinary ASCII for everything
You can use whatever editor you prefer and then pipe it into J as
needed
Or you can use the J editor and have all the immediate results, labs,
demos
helps, books at your fingertips.
All for free
www.jsoftware.com
Bj�rn Helgason wrote:
> Frank Buss wrote:
>
>>The translation of this J expression: +/'5'=":i.100 :
>>
>>(sum (list-eql #\5 (princ-to-string (make-seq 100))))
>>
>>But it could be done nearly as short as in J:
>
>
>
> +/'5'=":i.100
> 20
>
> sum=:+/
>
> what=:'5'
>
> equal=:=
>
> format=:":
>
> numbers=:i.100
>
> sum what equal format numbers
> 20
>
This is supposed to tell me something?
First of all what in heavens name is =:? Some languages use = for assignment,
some use :=, but what is =:?
OK, I'll jump to the conclusion (based on the structure of your sequence of
whatever they are, lines, statements, assertions, declarations, expressions,
utterances, you come up with more possibilities) that =: means "is defined to
be" similar to ::= in BNF.
sum=:+/ This is familiar from APL (presumably the APL content)
what=:'5' sum what seems to say that the thing to be summed is 5
equal=:= equal is defined to be =, can't argue with that
format=:": format is defined to be ": This explains a lot
numbers=:i.100 Ditto. Hard to decide which of the last two lines is more
illuminating.
sum what equal format numbers
20
So you summed 4 5's Where did the 4 come from?
Sorry for the somewhat sharp style of this post, but in my opinion a newsgroup
posting should be designed to illuminate and instruct. The linguae francae of
this news group are English for prose and APL for programming. If you are going
to explain to APL'ers what +/'5'=":i.100 means that might be useful, but do it
in English and/or APL or define your notation in those terms so that it is not a
message only for insiders from some other world.
James J. Weinkam wrote:
> Bj�rn Helgason wrote:
...
> First of all what in heavens name is =:? Some languages use = for
> assignment,
> some use :=, but what is =:?
>
> OK, I'll jump to the conclusion (based on the structure of your sequence of
> whatever they are, lines, statements, assertions, declarations,
> expressions,
> utterances, you come up with more possibilities) that =: means "is
> defined to
> be" similar to ::= in BNF.
>
> sum=:+/ This is familiar from APL (presumably the APL content)
>
> what=:'5' sum what seems to say that the thing to be summed is 5
>
> equal=:= equal is defined to be =, can't argue with that
>
> format=:": format is defined to be ": This explains a lot
>
> numbers=:i.100 Ditto. Hard to decide which of the last two lines is more
> illuminating.
>
> sum what equal format numbers
> 20
>
> So you summed 4 5's Where did the 4 come from?
I think he summed 20 1's; see below.
>
> Sorry for the somewhat sharp style of this post, but in my opinion a
> newsgroup
> posting should be designed to illuminate and instruct. The linguae
> francae of
> this news group are English for prose and APL for programming. If you
> are going
> to explain to APL'ers what +/'5'=":i.100 means that might be useful, but
> do it
> in English and/or APL or define your notation in those terms so that it
> is not a
> message only for insiders from some other world.
Clearly
+/'5'=":i.100
translates to
+/ '5' = {format} {iota} 100
20
(given that Bjorn said ": is 'format' and guessing that
iota =: i. }
IMO ... J orthography is, well, ummm, aah, sorry, but it's u g l y .
I wouldn't have thought that i. isn't one of the hard ones (for APLers)
to figure out, though.
Mike Kent wrote:
> James J. Weinkam wrote:
>
>> Bj�rn Helgason wrote:
>
> ...
>
>> First of all what in heavens name is =:? Some languages use = for
>> assignment,
>> some use :=, but what is =:?
>>
>> OK, I'll jump to the conclusion (based on the structure of your
>> sequence of
>> whatever they are, lines, statements, assertions, declarations,
>> expressions,
>> utterances, you come up with more possibilities) that =: means "is
>> defined to
>> be" similar to ::= in BNF.
>>
>> sum=:+/ This is familiar from APL (presumably the APL content)
>>
>> what=:'5' sum what seems to say that the thing to be summed is 5
>>
>> equal=:= equal is defined to be =, can't argue with that
>>
>> format=:": format is defined to be ": This explains a lot
>>
>> numbers=:i.100 Ditto. Hard to decide which of the last two lines is more
>> illuminating.
>>
>> sum what equal format numbers
>> 20
>>
>> So you summed 4 5's Where did the 4 come from?
>
>
> I think he summed 20 1's; see below.
>
>>
>> Sorry for the somewhat sharp style of this post, but in my opinion a
>> newsgroup
>> posting should be designed to illuminate and instruct. The linguae
>> francae of
>> this news group are English for prose and APL for programming. If you
>> are going
>> to explain to APL'ers what +/'5'=":i.100 means that might be useful,
>> but do it
>> in English and/or APL or define your notation in those terms so that
>> it is not a
>> message only for insiders from some other world.
>
>
> Clearly
>
> +/'5'=":i.100
>
> translates to
>
> +/ '5' = {format} {iota} 100
But that isn't what he said and it isn't clear until you are let in on the
secret. He said it translated to
add what equal format numbers.
You supplied the curly braces and broke up numbers into {iota} 100. His
translation sheds no light on what is a verb and what is a noun. The fact that
it is (as someone has said) valid J is neither here nor there. He was posting
to an APL newsgroup.
> 20
>
> (given that Bjorn said ": is 'format' and guessing that
"guessing" is the operative word. Why should the reader have to guess what the
poster is saying?
>
> iota =: i. }
>
> IMO ... J orthography is, well, ummm, aah, sorry, but it's u g l y .
>
Amen.
> I wouldn't have thought that i. isn't one of the hard ones (for APLers)
> to figure out, though.
I admit that I had guessed that as well, but the point of my post was that I
shouldn't have had to guess. If he is explaining something to someone why
doesn't he come out and explain it clearly and completely?
"Bj�rn Helgason" <······@gmail.com> writes:
> "He was posting to an APL newsgroup. "
>
> Actually he was posting to a Lisp newsgroup and so are you
For the Lisp people: the J/APL thing is rather like the Scheme/Lisp thing.
Christopher C. Stacy wrote:
> For the Lisp people: the J/APL thing is rather like the Scheme/Lisp thing.
And like academic politics, bitter because the stakes are low.
"Mike Kent" <·····@acm.org> wrote in message
····················@individual.net...
> Christopher C. Stacy wrote:
>
> > For the Lisp people: the J/APL thing is rather like the Scheme/Lisp
thing.
>
> And like academic politics, bitter because the stakes are low.
what an absolutely spot-on observation!
Bj�rn Helgason wrote:
> "If he is explaining something to someone why
> doesn't he come out and explain it clearly and completely?"
>
> What is it you do not understand?
>
J symbolism.
Bj�rn Helgason wrote:
>>IMO ... J orthography is, well, ummm, aah, sorry, but it's u g l y .
>
>
>
> Beauty's in the eye of the shareholder
Yes. That's what "IMO" means.
OTOH, my opinions fit the main stream so rarely I try to enjoy it
when they do.
>First of all what in heavens name is =:? Some languages use = for
assignment,
>some use :=, but what is =:?
=:? would assign ? which is Roll or Deal
>From the dictionary:
Roll:
"? y yields a uniform random selection from the population i.y if y is
a positive integer, or from the interval of numbers greater than or
equal to 0 and less than 1, if y is 0. The random seed used begins at
7^5 (16807). "
Deal:
"x ? y is a list of x items randomly chosen without repetition from i.y
"
> sum=:+/ This is familiar from APL (presumably the APL content)
defines sum to be +/
> what=:'5' sum what seems to say that the thing to be summed is 5
defines what is to be looked up
> equal=:= equal is defined to be =, can't argue with that
you are clever
> format=:": format is defined to be ": This explains a lot
yes
> numbers=:i.100 Ditto. Hard to decide which of the last two lines is
more
illuminating.
defines the numbers to be investigated
> sum what equal format numbers
> 20
here is a sum of how many fives there are in the formatted sequence of
numbers
> So you summed 4 5's Where did the 4 come from?
That is a mistery
" numbers=:i.100 "
i. is integers or index of
from the dictionary:
Integers:
"The shape of i.y is |y , and its atoms are the first */|y non-negative
integers. A negative element in y causes reversal of the atoms along
the corresponding axis. For example:
i. 5
0 1 2 3 4
i. 2 _5
4 3 2 1 0
9 8 7 6 5
"
Index of:
"If rix is the rank of an item of x, then the shape of the result of x
i. y is (-rix)}.$y . Each atom of the result is either #x or the index
of the first occurrence among the items of x of the corresponding
rix-cell of y .
The comparison in x i. y is tolerant, and fit can be used to specify
the tolerance, as in i. !. t .
"
Here i.100 is used to generate the integers and
numbers=:i.100
assigns those integers to numbers
numbers=:i.100
numbers
0 1 2 3 4 5 6 7 8 9 10 ....... and so on
in this form numbers can be used as numbers
2 + numbers
2 3 4 5 6 7 8 9 10 11 12 ..... and so on
When I change the numbers to text with format
format=:":
format numbers
0 1 2 3 4 5 6 7 8 9 10 ..... and so on
I can no longer use the as numbers
2 + format numbers
|domain error
| 2 +format numbers
But I can use equal to find where the number 5 is in the text
what=:'5'
equal=:=
what equal format numbers
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ....... and so
on
see more at www.jsoftware.com
···@zedat.fu-berlin.de (Stefan Ram) wrote:
> In Perl:
>
> map/5/g,0..100
ok, this has the same size as the J example, but in J you can write it one
char shorter, as Bj�rn Helgason wrote me by eMail:
+/'5'=":i.100
--
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Stefan Ram wrote:
>
> for(0..100){s/5/++$i/ge;}
>
> There is no part in it, that does not have to do with the idea
> of the solution. Those 25 characters are focused on the task.
> There is nothing unrelated or unnecessary. There is no
> overhead for anything unrelated such as "public static void
> main( String [] args )" would be in Java. Even the Lisp
> solution seems to be verbose compared with that.
>
> To me such a solution also is more readable, because the
> reader can concentrate on the idea of the process and is not
> distracted by administration code or unrelated keywords.
>
You are missing the point about Lisp. Abstraction is built up
by creating functions to help.
In real life if this problem needs to be used in many places
abstraction should and can be easily built. For me problem is not
how the solution is coded but in creating a form (in this case a function)
that expresses the problem. Something like this:
(defun count-digits-in-range (digit start end &optional (radix 10))
(assert (and (>= digit 0) (< digit radix)))
(let ((digit-char (char (format nil "~VR" radix digit) 0)))
(loop for number from start to end
sum (count digit-char (format nil "~VR" radix number)))))
CL-USER 29 > (count-digits-in-range 5 0 100)
20
CL-USER 30 > (count-digits-in-range 1 0 100 2)
319
CL-USER 31 > (count-digits-in-range 5 0 100 16)
22
CL-USER 32 > (count-digits-in-range 5 0 100 36)
3
CL-USER 39 > (count-digits-in-range 1 0 100 3)
150
Now count-digits-in-range does the absolute mininum and someone using it
does need to know how it works. This solution also allows a user
to specify the radix of the numbers because it has been built upon the
fore-sight of those that wrote format. For me comfort for the programmer is
secondary to those who need the abstraction. Lisp allows this building
up. Also not all verbosity is bad, just ask my wife if I need to talk more.
Wade
On Sat, 16 Apr 2005 16:02:11 +0000, Wade Humeniuk wrote:
> You are missing the point about Lisp. Abstraction is built up
> by creating functions to help.
And you might be missing the point about perl. Perl can abstract as well
as the next language, but instead users building mini languages out of a
base language, perl tends to absorb them and make the abstractions
idiomatic; kind of like a natural language. This is also a trait that is
often (sometimes with derision) ascribed to Common Lisp.
Matt
--
"You do not really understand something unless you can
explain it to your grandmother." — Albert Einstein.
···@zedat.fu-berlin.de (Stefan Ram) writes:
> The Perl solution to me seems very elegant because it contains
> exactly that idea and nothing more:
>
> for(0..100){s/5/++$i/ge;}
What about finding all prime numbers between 0 and 100? Doesn't work
with string substitutions (at least not as easily). I bet the perl
code would then look rather similar to the particular algorithm being
coded in other programming languages.
BTW. For someone who's not too experienced with perl (like me), the
above was not very clear. I had to think for a while until I
understood what it was probably doing.
mkb.
···@zedat.fu-berlin.de (Stefan Ram) writes:
> Matthias Buelow <···@incubus.de> writes:
> >What about finding all prime numbers between 0 and 100?
> >Doesn't work with string substitutions (at least not as
> >easily). I bet the perl code would then look rather similar to
> >the particular algorithm being coded in other programming
> >languages.
>
> You bet?
>
> for(0..100){print $_,' ' if(1 x $_)!~/^(11+)\1+$/}
>
> The output is:
>
> 0 1 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73
> 79 83 89 97
:-) Too much Turing machine programming lately?
What about the primes between 1000000000 and 1000000100?
mkb.
Stefan Ram <···@zedat.fu-berlin.de> wrote:
+---------------
| Recently a question was posed in TV about the number of "5"
| characters occuring within all integral decimal numerals
| between 0 and 100.
|
| Frank Buss suggested the following source code to
| calculate the result in Lisp:
...
| I wrote this in Perl:
+---------------
Actually, I don't like *any* of the (many) solutions presented! ;-}
This is a problem you should be doing in your head! QUICK! What's
the answer for 0-9? One, of course. And the answer for 0-99? One
for each decade, plus 10 for the 50's, or 20 [as many responded].
What about 0-999? 300. 0-9999? 4000. And 0-99999? 50000, duh!
Got the pattern yet...? ;-}
There's some ancient aphorism about this, something about *thinking*
first, before haring off to write code. But, hey, Gauss got in a lot
of trouble for thinking [Google for "Gauss sum class"], so I suppose
nobody does that any more.
This one is only slightly harder: Among the printed representations
of integers from 0 to (expt 10 n), how many contain *at least one* "5"?
Hint: ((1 . 1) (2 . 19) (3 . 271) ... )
-Rob
-----
Rob Warnock <····@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
From: Stefan Nobis
Subject: Re: "Higher Order Perl" book and Lisp
Date:
Message-ID: <87u0m4dpl8.fsf@snobis.de>
····@rpw3.org (Rob Warnock) writes:
> This one is only slightly harder: Among the printed representations
> of integers from 0 to (expt 10 n), how many contain *at least one* "5"?
> Hint: ((1 . 1) (2 . 19) (3 . 271) ... )
Hmmm... i only found this:
(defun f(n)
(let ((k (1- n)))
(if (= n 1)
1
(+ (expt 10 k) (* 9 (f k))))))
Has anyone found a non-recursive equation?
BTW: As i understand it, my solution is not tail-recursive. Is
there a way, to make the function tail-recursive?
--
Stefan.
"Stefan Nobis" <······@gmx.de> wrote in message ···················@snobis.de...
> ····@rpw3.org (Rob Warnock) writes:
>
>> This one is only slightly harder: Among the printed representations
>> of integers from 0 to (expt 10 n), how many contain *at least one* "5"?
>> Hint: ((1 . 1) (2 . 19) (3 . 271) ... )
>
> Hmmm... i only found this:
>
> (defun f(n)
> (let ((k (1- n)))
> (if (= n 1)
> 1
> (+ (expt 10 k) (* 9 (f k))))))
(defun f(n)
(let ((k (1- n)))
(if (zerop n)
0
(+ (expt 10 k) (* 9 (f k))))))
> Has anyone found a non-recursive equation?
Turn it on its head, start from zero, count up. :-)
> BTW: As i understand it, my solution is not tail-recursive. Is
> there a way, to make the function tail-recursive?
>
Use accumulators:
(defun f (n &optional (sum 0) (power-of-nine 1))
(if (zerop n)
sum
...
(f (1- n) new-sum new-power-of-nine)))
--
Geoff
From: Björn Lindberg
Subject: Re: "Higher Order Perl" book and Lisp
Date:
Message-ID: <4263a516@news.cadence.com>
Stefan Ram wrote:
> Frank Buss suggested the following source code to
> calculate the result in Lisp:
>
> (loop for i from 0 to 100 with c = 0 finally (return c) do
> (loop for d across (format nil "~A" i) do (when (char= d #\5) (incf c))))
>
> I wrote this in Perl:
>
> for(0..100){s/5/++$i/ge;}print $i;
>
> I like the Perl-solution, and here's why:
>
> First, let my write in natural language what I want to do:
>
> "For each numeral from 0 to 100: I want to count each
> occurence of the digit '5'."
>
> The Perl solution to me seems very elegant because it contains
> exactly that idea and nothing more:
>
> for(0..100){s/5/++$i/ge;}
>
> There is no part in it, that does not have to do with the idea
> of the solution. Those 25 characters are focused on the task.
> There is nothing unrelated or unnecessary. There is no
> overhead for anything unrelated such as "public static void
> main( String [] args )" would be in Java. Even the Lisp
> solution seems to be verbose compared with that.
>
> To me such a solution also is more readable, because the
> reader can concentrate on the idea of the process and is not
> distracted by administration code or unrelated keywords.
Yes, If all your programming tasks have this magnitude of complexity, by
all means use perl.
Bj�rn
>
> Indeed. One of the hardest things for me to accept when I switched
> from perl to the "right way" was the total absence of anything
> approaching CPAN in the older language. When I started my project in
> perl some time ago, I had code running in about 30 minutes, since I
> could grab a dozen packages off of CPAN, shove them together and go.
> In CL, packages exist for the datastore and maybe some of the front
> end, everything else I need to create (but at least I have a roadmap).
>
> I suspect that CL will never get anywhere close to CPAN, Lispers just
> have so much power to do things their own way (down to the dotting of
> i) that strong herd groups will simply never happen. It is the kind
> of thinking that made single user Lisp Machines (whereas even Windows
> 3.1 had some token attempt at multiuser). I like it.
>
How about some lisp bindings to Perl? Embed perl in your lisp
application, use perl libraries, do application logic in lisp.
On Sat, 16 Apr 2005 18:20:48 +0100, <·····@ph.com> wrote:
>
>
>>
>> Indeed. One of the hardest things for me to accept when I switched
>> from perl to the "right way" was the total absence of anything
>> approaching CPAN in the older language. When I started my project in
>> perl some time ago, I had code running in about 30 minutes, since I
>> could grab a dozen packages off of CPAN, shove them together and go.
>> In CL, packages exist for the datastore and maybe some of the front
>> end, everything else I need to create (but at least I have a roadmap).
>>
>> I suspect that CL will never get anywhere close to CPAN, Lispers just
>> have so much power to do things their own way (down to the dotting of
>> i) that strong herd groups will simply never happen. It is the kind
>> of thinking that made single user Lisp Machines (whereas even Windows
>> 3.1 had some token attempt at multiuser). I like it.
>>
>
> How about some lisp bindings to Perl? Embed perl in your lisp
> application, use perl libraries, do application logic in lisp.
You might want to read the last sentence again.
No reason whatsoever to link into perl, it's at least 30 times
slower...and that's before the genetic algorithm decision tree logic
(and it's required validation in perl) kick in.
As suggested elsewhere, I simply "sight-read" my own perl code, and it
should be easy to understand it at least ;-) , and write lisp code to
replace it. The difficulty is learning enough lisp to efficiently
perform the translation. The payoff is enough speed to be useful
real-time, and the power to have effective decision trees in
real-time. Not bad for a dead, maligned language.
--
Everyman has three hearts;
one to show the world, one to show friends, and one only he knows.
"Eli Bendersky" <······@gmail.com> wrote in message
····························@f14g2000cwb.googlegroups.com...
> Hi All,
>
> MJD, a well known Perl hacker, has written a new Perl book
> named "Higher Order Perl". In this book, he takes on a path
> that basically teaches one to think Lispily while writing
> Perl. Here is an interview with him that you may find interesting:
> http://www.theperlreview.com/Interviews/mjd-hop-20050407.html?up
>
> Some notable quotes:
>
...
> * But I find Haskell and SML more attractive, for various reasons. One
> is that the Lisp user community is severely dysfunctional. Another is
I think this is just old news. Things have changed alot in the last few
years.
--
Coby Beck
(remove #\Space "coby 101 @ bigpond . com")
On Sat, 16 Apr 2005 16:53:07 GMT, "Coby Beck" <·····@mercury.bc.ca>
wrote:
>"Eli Bendersky" <······@gmail.com> wrote in message
>····························@f14g2000cwb.googlegroups.com...
>> Hi All,
>>
>> MJD, a well known Perl hacker, has written a new Perl book
>> named "Higher Order Perl". In this book, he takes on a path
>> that basically teaches one to think Lispily while writing
>> Perl. Here is an interview with him that you may find interesting:
>> http://www.theperlreview.com/Interviews/mjd-hop-20050407.html?up
>>
>> Some notable quotes:
...
>> * But I find Haskell and SML more attractive, for various reasons. One
>> is that the Lisp user community is severely dysfunctional. Another is
>
>I think this is just old news. Things have changed alot in the last few
>years.
As a Lisp newbie, how so?
I really like Lisp, but it strikes me as a hard language to evangelize
within an organization. It's advantages are not easy to describe in
sound-bites. Whereas, the fantastic libraries of Java or Perl are easy
to demonstrate. The things that make languages like Java or C# or Perl
popular with managers are
* lots of free libraries and frameworks
* cross-platform (in the sense that a given script will work without
special effort or changes)
* IDE / whiz-bang GUI tools that demo well (NOT Emacs)
* Airplane-magazine buzz
* "Big Company" support
* works for average programmers
* Already popular (and therefore has programmers, etc.)
Not all elements need to apply, but these are the kinds of things that
help. Lisp doesn't do well by these criteria, so people like myself
who would _like_ to evangelize need a better angle of attack.
--
adamnospamaustin.rr.com
s/nospam/c\./
"Adam Connor" <···@nospam.com> wrote in message
·······································@4ax.com...
> On Sat, 16 Apr 2005 16:53:07 GMT, "Coby Beck" <·····@mercury.bc.ca>
> wrote:
>
>>"Eli Bendersky" <······@gmail.com> wrote in message
>>····························@f14g2000cwb.googlegroups.com...
>>> Hi All,
>>>
>>> MJD, a well known Perl hacker, has written a new Perl book
>>> named "Higher Order Perl". In this book, he takes on a path
>>> that basically teaches one to think Lispily while writing
>>> Perl. Here is an interview with him that you may find interesting:
>>> http://www.theperlreview.com/Interviews/mjd-hop-20050407.html?up
>>>
>>> Some notable quotes:
> ...
>>> * But I find Haskell and SML more attractive, for various reasons. One
>>> is that the Lisp user community is severely dysfunctional. Another is
>>
>>I think this is just old news. Things have changed alot in the last few
>>years.
>
> As a Lisp newbie, how so?
I took the comment to be about our little usenet world here, so that's what
my response was refering to. I don't expect things are much different in
terms of general attitudes about lisp in the non-lisp world.
--
Coby Beck
(remove #\Space "coby 101 @ bigpond . com")