User: Password:
|
|
Subscribe / Log in / New account

Should be: Goodnight, Perl 6.

Should be: Goodnight, Perl 6.

Posted Feb 14, 2013 12:21 UTC (Thu) by fatrat (subscriber, #1518)
In reply to: Should be: Goodnight, Perl 6. by raiph
Parent article: Chromatic: Goodnight, Parrot

How does this differ from the Haskell (or Python version)

ghci> [ x+y | x <- [1,2,3], y <- [4,5,6] ]
[5,6,7,6,7,8,7,8,9]

which seems cleaner.

In Haskell, that can also deal with lazy lists etc


(Log in to post comments)

Should be: Goodnight, Perl 6.

Posted Feb 14, 2013 17:41 UTC (Thu) by hummassa (subscriber, #307) [Link]

Cleaner than

> 1, 2, 3 X+ 4, 5, 6
5 6 7 6 7 8 7 8 9

? ok then.

Should be: Goodnight, Perl 6.

Posted Feb 14, 2013 18:22 UTC (Thu) by raiph (guest, #89283) [Link]

> How does this differ from the Haskell (or Python version)
> ghci> [ x+y | x <- [1,2,3], y <- [4,5,6] ]
> [5,6,7,6,7,8,7,8,9]

That's the same.

One issue is whether you prefer, from an expressivity point of view, x+y or something like add(x,y). I usually prefer x+y. It looks like, for the "familar" function/operator add/+, we all agree: x+y is generally preferable.

So what about "unfamiliar" functions/operators? I'm going to guess at the haskell syntax for a zipped string concat:

zipwith (++) ["foo", "bar"] ["sing", "song"].

Perl 6 uses ~ instead of ++ and supports infix notation so one can write:

["foo", "bar"] Z~ ["sing", "song"]

It seems alankila and k8to (and you?) consider the Z~ infix notation for zipped string concat to be less clear.

Let's assume for a moment that this is just a syntax sugar issue. (Regardless of whether the sugar seems sweet or not to any given writer/reader.) Given that Perl 6 is aiming at (among other things) being a metaDSL (a language for easily expressing and combining DSLs) then sugar matters and it's potentially important to make it trivial to use a wide range of expressivity, including infix notation, for user defined functions/operators (as well as builtins of course).

Should be: Goodnight, Perl 6.

Posted Feb 14, 2013 19:34 UTC (Thu) by nybble41 (subscriber, #55106) [Link]

Haskell doesn't let you mix letters and symbols in operator names, but apart from that it's simple to define an operator similar to Z~ which works on any nested list type, including lists of strings ([[Char]]):

infixr 6 ++~
(++~) = zipWith (++)

["foo", "bar"] ++~ ["sing", "song"]

Should be: Goodnight, Perl 6.

Posted Feb 14, 2013 21:40 UTC (Thu) by fatrat (subscriber, #1518) [Link]

I think my issues is that the [ ... ] list/monad comprehension approach is very general, and, as nybble41 points out, can be specialised as needed.

The Perl6 approach seems to lead to a proliferation of operators, and consequent maintenance issues.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds