Main Page | Report Page

 

  Computers Forum Index » Computer Languages (Functional) » What's List Comprehension and Why is it Harmful?...

Author Message
Xah Lee...
Posted: Mon Oct 18, 2010 9:59 am
 
On Oct 18, 2:34 am, Marc Mientki <mien... at (no spam) nonet.com> wrote:
Quote:
One question: why contain your pages always this junk? (red marked):
   http://img256.imageshack.us/img256/7618/xahleehtmljunk.jpg

regards
Marc

ug. what browser + OS are you using?

those are unicode 「」
LEFT CORNER BRACKET x300c
RIGHT CORNER BRACKET x300d

you might be missing font

• 〈Best Fonts for Unicode〉
http://xahlee.org/emacs/emacs_unicode_fonts.html

or you might need to tweak your browser's encoding/decoding and font.
you can see the same article at these locations,

http://groups.google.com/group/comp.lang.lisp/browse_frm/thread/d1a7f83dd4ee736b#
http://xahlee.blogspot.com/2010/10/whats-list-comprehension-and-why-is-it.html
http://xahlee.org/comp/list_comprehension.html

possibly your browser will display correctly in one but not other...
these days it's complicated to trace the cause.

thanks for your screenshot. That's good to know. Please let me know
your browser, version, and OS.

Xah ∑ http://xahlee.org/
 
Xah Lee...
Posted: Mon Oct 18, 2010 10:29 am
 
On Oct 18, 3:03 am, Marc Mientki <mien... at (no spam) nonet.com> wrote:
Quote:
Am 18.10.2010 11:59, schrieb Xah Lee:

On Oct 18, 2:34 am, Marc Mientki<mien... at (no spam) nonet.com>  wrote:
One question: why contain your pages always this junk? (red marked):
   http://img256.imageshack.us/img256/7618/xahleehtmljunk.jpg

regards
Marc

ug. what browser + OS are you using?

Firefox 3.6.10 on windows XP + SP3.

those are unicode 「」
LEFT CORNER BRACKET x300c
RIGHT CORNER BRACKET x300d

Is there need for unicode for such trivial things like {[]}?

short story is no but am a unicode geek :)

long story is... i need a way to quote code... the corner bracket was
choosen because it's standard chinese punctuation thus almost all
computer today bought in the past 5 years can display it, and because
it's different than ascii so it avoids ambiguity and complications.
e.g. when the quoted text also contains the char that you use for
quoting....

thanks for your info. I'll think about removing them...

the other thing is that those markers are very useful when you think
about info processing and automation. e.g. in the future i can
trivially write a script list all inline code i have on my site, or to
htmlize/css all quoted code. e.g.

• 〈Unix Shell Text Processing Tutorial (grep, cat, awk, sort, uniq)〉
http://xahlee.org/UnixResource_dir/unix_shell_text_processing.html

in that page, does the char show up correctly? The chars are not in
the html text, but is added by CSS due to markup. And the code are all
colored red.

PS: the most popular example of studious use of quoting in a tech doc
is emacs manual or any manual from FSF. e.g.

• 〈Constant-Variables〉
http://xahlee.org/elisp/Constant-Variables.html

but however, they use ascii hack of the 1970s, e.g. like `this' and
``this''.

Xah ∑ http://xahlee.org/
 
Marc Mientki...
Posted: Mon Oct 18, 2010 1:34 pm
 
One question: why contain your pages always this junk? (red marked):
http://img256.imageshack.us/img256/7618/xahleehtmljunk.jpg

regards
Marc
 
Marc Mientki...
Posted: Mon Oct 18, 2010 2:03 pm
 
Am 18.10.2010 11:59, schrieb Xah Lee:
Quote:
On Oct 18, 2:34 am, Marc Mientki<mien... at (no spam) nonet.com> wrote:
One question: why contain your pages always this junk? (red marked):
http://img256.imageshack.us/img256/7618/xahleehtmljunk.jpg

regards
Marc

ug. what browser + OS are you using?

Firefox 3.6.10 on windows XP + SP3.


Quote:
those are unicode 「」
LEFT CORNER BRACKET x300c
RIGHT CORNER BRACKET x300d

Is there need for unicode for such trivial things like {[]}?

regards
Marc
 
Nobody...
Posted: Mon Oct 18, 2010 6:14 pm
 
On Mon, 18 Oct 2010 12:03:12 +0200, Marc Mientki wrote:

Quote:
ug. what browser + OS are you using?

Firefox 3.6.10 on windows XP + SP3.

FWIW, I'm using FF 3.6.4 on XP+SP3, and I have no problems with that page.

You should check your font settings.
 
Nobody...
Posted: Mon Oct 18, 2010 6:32 pm
 
On Mon, 18 Oct 2010 02:11:07 -0700, Xah Lee wrote:

Quote:
• List Comprehension is a redundant concept in programing. What List
Comprehension does is simply 「map(func, filter(list, predicate))」.

You're assuming a single generator. Once you have multiple generators,
map + filter + concat starts getting ugly rather quick.

FWIW, I this:

[(x,y) | x <- [1..5], y <- [1..x]]

clearer than either this:

concat (map (\x -> map ((,) x) [1..x]) [1..5])

or this:

concat (map (\x -> map (\y -> (,) x y) [1..x]) [1..5])
 
w_a_x_man...
Posted: Mon Oct 18, 2010 6:50 pm
 
On Oct 18, 4:11\xA0am, Xah Lee <xah... at (no spam) gmail.com> wrote:
Quote:
here's a article about list comprehension.



Quote:

Here's a example of LC in python:

S = [2*n for n in range(0,9) if ( (n % 2) == 0)]
print S
# prints [0, 4, 8, 12, 16]



Ruby:

(0..9).select{|n| n.even?}.map{|n| 2*n}
==>[0, 4, 8, 12, 16]

shorter:

(0..9).select( &:even? ).map{|n| 2*n}
==>[0, 4, 8, 12, 16]




Quote:

The jargon "list comprehension" is opaque. It hampers communication
and increases misunderstanding. A better name is simply "list
generator".


+1
 
Xah Lee...
Posted: Tue Oct 19, 2010 12:29 am
 
On Oct 18, 11:50 am, w_a_x_man <w_a_x_... at (no spam) yahoo.com> wrote:
Quote:
On Oct 18, 4:11\xA0am, Xah Lee <xah... at (no spam) gmail.com> wrote:

here's a article about list comprehension.

Here's a example of LC in python:

S = [2*n for n in range(0,9) if ( (n % 2) == 0)]
print S
# prints [0, 4, 8, 12, 16]

Ruby:

(0..9).select{|n| n.even?}.map{|n| 2*n}
    ==>[0, 4, 8, 12, 16]

shorter:

(0..9).select( &:even? ).map{|n| 2*n}
    ==>[0, 4, 8, 12, 16]



The jargon "list comprehension" is opaque. It hampers communication
and increases misunderstanding. A better name is simply "list
generator".

+1

thanks a lot wax man. I added your example with credit.

over the past few years, you've posted lots snippets of ruby code, and
i find them quite interesting, and those snippets gave me quite a
positive view of ruby.

btw, is unicode still a problem with ruby? i really need robust
unicode for my use.

also, if you can tell me, what's the main discussion group for ruby?
is it just comp.lang.ruby or is it web based forum?

Xah ∑ http://xahlee.org/
 
w_a_x_man...
Posted: Tue Oct 19, 2010 1:49 am
 
On Oct 18, 7:29pm, Xah Lee <xah... at (no spam) gmail.com> wrote:
Quote:
On Oct 18, 11:50am, w_a_x_man <w_a_x_... at (no spam) yahoo.com> wrote:

On Oct 18, 4:11\xA0am, Xah Lee <xah... at (no spam) gmail.com> wrote:

here's a article about list comprehension.

Here's a example of LC in python:

S = [2*n for n in range(0,9) if ( (n % 2) == 0)]
print S
# prints [0, 4, 8, 12, 16]

Ruby:

(0..9).select{|n| n.even?}.map{|n| 2*n}
==>[0, 4, 8, 12, 16]

shorter:

(0..9).select( &:even? ).map{|n| 2*n}
==>[0, 4, 8, 12, 16]

The jargon "list comprehension" is opaque. It hampers communication
and increases misunderstanding. A better name is simply "list
generator".

+1

thanks a lot wax man. I added your example with credit.

over the past few years, you've posted lots snippets of ruby code, and
i find them quite interesting, and those snippets gave me quite a
positive view of ruby.

btw, is unicode still a problem with ruby? i really need robust
unicode for my use.

Sorry, but I'm clueless about unicode. (It does seem strange that
a language from Japan has not always had great unicode support.)

Quote:

also, if you can tell me, what's the main discussion group for ruby?
is it just comp.lang.ruby or is it web based forum?

I believe it's comp.lang.ruby. Posts at www.ruby-forum.com/forum/ruby
are forwarded to the newsgroup.
 
namekuseijin...
Posted: Tue Oct 19, 2010 2:14 am
 
On 18 out, 16:50, w_a_x_man <w_a_x_... at (no spam) yahoo.com> wrote:
Quote:
On Oct 18, 4:11\xA0am, Xah Lee <xah... at (no spam) gmail.com> wrote:

here's a article about list comprehension.

Here's a example of LC in python:

S = [2*n for n in range(0,9) if ( (n % 2) == 0)]
print S
# prints [0, 4, 8, 12, 16]

Ruby:

(0..9).select{|n| n.even?}.map{|n| 2*n}
==>[0, 4, 8, 12, 16]

shorter:

(0..9).select( &:even? ).map{|n| 2*n}
==>[0, 4, 8, 12, 16]

idiomatic python:
[2*n for n in range(9) if n%2==0]

custom syntax is always shorter and more convenient in direct style:
that's precisely why they made it into custom syntax in the first
place.

Of course, that's far better in a language that allows user-defined
custom syntax. waxhead only agreed with you because ruby got no
custom list comprehension syntax nor a way to define one: if it was a
builtin he'd gladly use it everywhere instead of actually making an
algorithm actually describing how it works, as he always does...
 
Peter Keller...
Posted: Tue Oct 19, 2010 2:50 am
 
In comp.lang.lisp Xah Lee <xahlee at (no spam) gmail.com> wrote:
Quote:
hi Peter,

thanks for the thoughts.

It seems to me your action is simply composition, which is available
in many functional langs.

That's true, but composition and list comprehensions should go hand in hand,
but with a specific syntax, it is uglier.

Quote:
you added a sorta trace functionality to composition. In Mathematica,
any lisp function (say named xyz), usually have a xyzList version,
which returns all the steps as a list. This is somewhat similar to
your trace. Some functional lang has this too i think. But in general,
i don't see the utility of your trace action kinda thing. It seems
like a domain specific lang's need.

It is very useful for recording mutations of a tree walker and
extendable to recording mutations of a graph walker. The important
aspect is that if the actions are invertible, you get a piecewise
bijection from the original graph to the resultant one.

Later,
-pete
 
Xah Lee...
Posted: Tue Oct 26, 2010 7:23 am
 
http://www.reddit.com/r/programming/comments/dw8op/whats_list_comprehension_and_why_is_it_harmful/
On Oct 18, 10:00am, Peter Keller <psil... at (no spam) cs.wisc.edu> wrote:
Quote:
In comp.lang.lisp Xah Lee <xah... at (no spam) gmail.com> wrote:
What's List Comprehension and Why is it Harmful

the case hits reddit.

http://www.reddit.com/r/programming/comments/dw8op/whats_list_comprehension_and_why_is_it_harmful/

sometimes i do find some reddit replies interesting and knowledgable
(like slashdot), but am afraid 99% of it is uninformed garbage. In
this case, i haven't found a interesting argument. Though, it is
informative that many reddit readers didn't find my article
interesting. A
good feed back that i need to edit or expand it, with more examples,
etc.

Xah
 
Marek Kubica...
Posted: Tue Oct 26, 2010 8:32 pm
 
On Mon, 18 Oct 2010 03:29:12 -0700 (PDT)
Xah Lee <xahlee at (no spam) gmail.com> wrote:

Quote:
long story is... i need a way to quote code... the corner bracket was
choosen because it's standard chinese punctuation thus almost all
computer today bought in the past 5 years can display it, and because
it's different than ascii so it avoids ambiguity and complications.
e.g. when the quoted text also contains the char that you use for
quoting....

Most people just use typewriter-fixed-width fonts for that...

regards,
Marek
 
 
Page 1 of 1    
All times are GMT
The time now is Wed Jul 23, 2014 6:06 pm