Re: Amazing Perl 6

2009-06-01 Thread Larry Wall
On Sun, May 31, 2009 at 04:45:12PM -0400, Brandon S. Allbery KF8NH wrote:
 On May 29, 2009, at 15:43 , John M. Dlugosz wrote:
 Care to try ☃ ?  That's alt-meta-hyper-doublebucky-cokebottle.


 *puzzled as to why OSX Character Map thinks that's related to 雪*

Maybe they can't tell the diffence between snowman and snow?
(By the way, if you know any 日本人 named Yuki, they probably
write their name with 雪.  Which is a really cool (no pun intended)
character--if you look at the two radicals, it basically means
precipitation you can grasp.  :)

Larry


Re: Amazing Perl 6

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 27, 2009, at 13:59 , Daniel Carrera wrote:
Wow... That's a foldl! In a functional language, that would be  
called a fold. It's very popular in Haskell.


I like that Perl 6 seems to be taking steps in the direction of  
functional languages. First lazy lists (0..Inf) and now a fold. :-D



One of the early P6 prototypes was written in Haskell, and there's  
been a lot of notions lifted from it.  (OTOH being an old phart I know  
[OP] @list as op/list :)


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: Amazing Perl 6

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 27, 2009, at 15:42 , Daniel Carrera wrote:

Mark J. Reed wrote:
Note that of the examples given, only Perl 6 and Common Lisp do two  
things

that help immensely simplify the result:
1. reference the built-in * operator directly, without having to  
wrap it in

a lambda expression;
2. actually name the function !


Yes, very neat. Haskell does that too, but I don't know if you can  
make the function a postfix in Haskell.



Not in H98, but ghc allows it as a degenerate form of section.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: Amazing Perl 6

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 27, 2009, at 18:05 , John M. Dlugosz wrote:

And APL calls it |¨ (two little dots high up)



buh?  Metaoperator / (+/LIST).

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: Amazing Perl 6

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 28, 2009, at 06:43 , Jon Lang wrote:

What I'm wondering is how the list knows to feed two items into '[+]'.
While 'infix:+' must accept exactly two arguments, '[+]' can accept
an arbitrarily long (or short) list of arguments.



I thought that at first too, then remembered a discussion about  
generalizing the meaning of square brackets and how [op] fell out of  
it automatically to take a reference to an operator without using the  
infix:op syntax.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: Amazing Perl 6

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 29, 2009, at 15:43 , John M. Dlugosz wrote:

Care to try ☃ ?  That's alt-meta-hyper-doublebucky-cokebottle.



*puzzled as to why OSX Character Map thinks that's related to 雪*

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: Amazing Perl 6

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 29, 2009, at 21:50 , Timothy S. Nelson wrote:
some Linux programs support it too.  Unfortunately my e-mail program  
(Pine) seems to have some trouble with unicode -- I may have to look  
at alternatives after 14 years of use :(.



http://www.washington.edu/alpine/

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: Amazing Perl 6

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 29, 2009, at 22:40 , Timothy S. Nelson wrote:

On Fri, 29 May 2009, John M. Dlugosz wrote:
Ah yes, on the PC historically you hold down the ALT key and type  
the code with the numpad keys.


	At least when I used it, this was a decimal, rather than hex  
number, and had to be preceded by a 0 (zero).



I see ALT+ a lot in Windows stuff, and have used it a few times  
(that is, while holding Alt type + and 4 hex digits).


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: Amazing Perl 6

2009-05-30 Thread John M. Dlugosz
The same tradition has variations in Windows.  I recall the leading zero 
means ANSI code page.  I thought I recall a way to give more digits and 
specify Unicode, but I can't find it on Google.


--John

Timothy S. Nelson wayland-at-wayland.id.au |Perl 6| wrote:

On Fri, 29 May 2009, John M. Dlugosz wrote:

Ah yes, on the PC historically you hold down the ALT key and type the 
code with the numpad keys.


At least when I used it, this was a decimal, rather than hex 
number, and had to be preceded by a 0 (zero).


So if anyone is still on eg. Windows 98, this may be the way to go 
:).



-
| Name: Tim Nelson | Because the Creator is,|
| E-mail: wayl...@wayland.id.au| I am   |
-

BEGIN GEEK CODE BLOCK
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- PE(+) Y+++ 
PGP-+++ R(+) !tv b++ DI D G+ e++ h! y-

-END GEEK CODE BLOCK-





Re: Amazing Perl 6

2009-05-29 Thread Tom Christiansen
· Quoth Larry:

˸ So let’s not make the mistake of thinking something
˸ longer is always less confusing or more official.

⋮ I already have too much problem with people thinking the
⋮ efficiency of a perl construct is related to its length.

So you’re saying the Law of Parsimony has its uses… a̲n̲d̲ abuses? ☻

--tom

-- 
ENTIA 
  NON · SVNT 
   M V L T I P L I C A N D A 
PRÆTER 
 N̳E̳C̳E̳S̳S̳I̳T̳A̳T̳E̳M̳


Re: Amazing Perl 6

2009-05-29 Thread John Macdonald
On Thu, May 28, 2009 at 08:10:41PM -0500, John M. Dlugosz wrote:
 John Macdonald john-at-perlwolf.com |Perl 6| wrote:
 However, the assumption fails if process is supposed to mean that
 everyone is capable of generating Unicode in the messages that they
 are writing.  I don't create non-English text often enough to have
 it yet be useful to learn how.  (I'd just forget faster than I'd use
 it and have to learn it again each time - but Perl 6 might just be
 the tipping point to make learning Unicode composition worthwhile.)
   


 Just copy/paste from another message or a web page.  Perhaps a web page  
 designed for that purpose...

Yep, I've done that.

But comparing the difference in effort between:

- press a key
- Google for a web page that has the right character set, cut, refocus, paste

means that I don't bother for the one or two weird characters
every few months that is my current Unicode usage.  If I were
working with Unicode frequently, it would be worth setting up
links and mechanisms, or learning the keyboard compose sequences
for frequently used characters.  I'm sure that there are many
people in a similar situation.


Re: Amazing Perl 6

2009-05-29 Thread Jon Lang
On Fri, May 29, 2009 at 6:52 AM, John Macdonald j...@perlwolf.com wrote:
 Yep, I've done that.

 But comparing the difference in effort between:

 - press a key
 - Google for a web page that has the right character set, cut, refocus, paste

 means that I don't bother for the one or two weird characters
 every few months that is my current Unicode usage.  If I were
 working with Unicode frequently, it would be worth setting up
 links and mechanisms, or learning the keyboard compose sequences
 for frequently used characters.  I'm sure that there are many
 people in a similar situation.

Agreed.  Given the frequency with which « and » come up in Perl 6, I'd
love to be able to have a simple keyboard shortcut that produces these
two characters.  Unfortunately, I am often stuck using a Windows
system when coding; and the easiest method that I have available to me
there (that I know of) is to pull up Character Map.

-- 
Jonathan Dataweaver Lang


Re: Amazing Perl 6

2009-05-29 Thread Buddha Buck
On Fri, May 29, 2009 at 10:23 AM, Jon Lang datawea...@gmail.com wrote:
 On Fri, May 29, 2009 at 6:52 AM, John Macdonald j...@perlwolf.com wrote:
 Yep, I've done that.

 But comparing the difference in effort between:

 - press a key
 - Google for a web page that has the right character set, cut, refocus, paste

 means that I don't bother for the one or two weird characters
 every few months that is my current Unicode usage.  If I were
 working with Unicode frequently, it would be worth setting up
 links and mechanisms, or learning the keyboard compose sequences
 for frequently used characters.  I'm sure that there are many
 people in a similar situation.

 Agreed.  Given the frequency with which « and » come up in Perl 6, I'd
 love to be able to have a simple keyboard shortcut that produces these
 two characters.  Unfortunately, I am often stuck using a Windows
 system when coding; and the easiest method that I have available to me
 there (that I know of) is to pull up Character Map.

In response to this thread, I activated the US International
keyboard layout, and once that's done theoretically one can get
Spanish style quote mark with RightAlt+[ and RightAlt+] like so: «
and ».

The questions which remain (for me, at least) is if (a) the symbols
survive in email, and (b) if they really are the proper marks for
Perl6.


 --
 Jonathan Dataweaver Lang



Re: Amazing Perl 6

2009-05-29 Thread Austin Hastings


Jon Lang wrote:

Agreed.  Given the frequency with which « and » come up in Perl 6, I'd
love to be able to have a simple keyboard shortcut that produces these
two characters.  Unfortunately, I am often stuck using a Windows
system when coding; and the easiest method that I have available to me
there (that I know of) is to pull up Character Map


Set your keyboard to us-international. There's a bunch of goodies in 
there. The problem is the delayed keystrokes on composed accented 
characters, formed by quote+letter. (like 'a)


So write your own keyboard module. I did one for P6 several years ago.

In the mean time, it's alt+shift, altgr+[

=Austin


Re: Amazing Perl 6

2009-05-29 Thread Mark J. Reed
On Fri, May 29, 2009 at 10:56 AM, Austin Hastings
austin_hasti...@yahoo.com wrote:
 Agreed.  Given the frequency with which « and » come up in Perl 6, I'd
 love to be able to have a simple keyboard shortcut that produces these
 two characters.

Windows; set keyboard to US-International.  Right-alt + [ and ].

Mac (standard US keyboard): option + \ for «, same key shifted for »

Linux: Lots of variables: X input manager, modifier keymap, etc.  But
digraphs work in vim: control-K   and control-K  

-- 
Mark J. Reed markjr...@gmail.com


Re: Amazing Perl 6

2009-05-29 Thread yary
Back to the question of cool things about perl6- after showing some
of the extended syntax and its expressiveness, put up a slide saying
it's still Perl.

Show that much of the basics still work:
 my @x=('a' .. 'z'); @x[3,4]=qw(DeeDee Ramone);
  say @x.splice(2,4).join(',')
c,DeeDee,Ramone,f

the splice and join as methods instead of subs is different in p6 then
p5 but should still look familiar. And if that is too harsh there's

use v5

so one can use the old syntax, if there's a want or need to.

The real benefit/amazing thing about perl6's back-compatibility is the
ability to still use the substantial mass of code libraries in cpan-

use Catalyst;

Huge plus there!

It's good to show/remind people that their investment in perl is still
valid when they pick up perl v6. That's one of the amazing things.
IMHO, it is really cool that the perl6 specs mandate that older perl
modules will work... just as I was happy that perl 5.0 let me use my
old perl 4 packages, with single quotes instead of :: and all...

I'd also like to help nip in the bud a tendency to view perl v6 as a
different language from perl v5. Along those lines, might be worth
mentioning how perl 6 is already leaking into perl 5.10+, things such
as say, the smart-match operator ~~, and various cpan modules that
implement perl v6 features like gather/take in perl v5.


Re: Amazing Perl 6

2009-05-29 Thread Larry Wall
On Fri, May 29, 2009 at 10:47:44AM -0400, Buddha Buck wrote:
: The questions which remain (for me, at least) is if (a) the symbols
: survive in email, and (b) if they really are the proper marks for
: Perl6.

Yes, and yes.

Me, I just defined a compose key, and compose  does the right thing.
(though I often use ^K in vim).

Larry


Re: Amazing Perl 6

2009-05-29 Thread Larry Wall
On Fri, May 29, 2009 at 09:50:36AM -0700, yary wrote:
: Back to the question of cool things about perl6- after showing some
: of the extended syntax and its expressiveness, put up a slide saying
: it's still Perl.
: 
: Show that much of the basics still work:
:  my @x=('a' .. 'z'); @x[3,4]=qw(DeeDee Ramone);
:   say @x.splice(2,4).join(',')
: c,DeeDee,Ramone,f

That qw is not a good example of what still works, since it is supposed
to be interpreted as a qw subroutine (rakudo bug).  I recommend square
brackets instead.

Larry


Re: Amazing Perl 6

2009-05-29 Thread John M. Dlugosz

John Macdonald john-at-perlwolf.com |Perl 6| wrote:

On Thu, May 28, 2009 at 08:10:41PM -0500, John M. Dlugosz wrote:
  

John Macdonald john-at-perlwolf.com |Perl 6| wrote:


However, the assumption fails if process is supposed to mean that
everyone is capable of generating Unicode in the messages that they
are writing.  I don't create non-English text often enough to have
it yet be useful to learn how.  (I'd just forget faster than I'd use
it and have to learn it again each time - but Perl 6 might just be
the tipping point to make learning Unicode composition worthwhile.)
  
  
Just copy/paste from another message or a web page.  Perhaps a web page  
designed for that purpose...



Yep, I've done that.

But comparing the difference in effort between:

- press a key
- Google for a web page that has the right character set, cut, refocus, paste

means that I don't bother for the one or two weird characters
every few months that is my current Unicode usage.  If I were
working with Unicode frequently, it would be worth setting up
links and mechanisms, or learning the keyboard compose sequences
for frequently used characters.  I'm sure that there are many
people in a similar situation.
  
I noticed I Wikipedia that the edit page now has a selection at the 
bottom.  Very handy.  I usually use BabelMap to explore characters and 
also copy them to the clipboard.


But a while back I started writing a book on basic science for kids and 
curious adults, and started off with scientific notation.  The crosses, 
dots, and math-minus was driving my nuts, in such quantity as to prevent 
the flow of thought.  So I bought a 16-button X-keys strip.  Turns out 
the software stinks to high heaven and was essentially useless (hmm, 
what's the point, then?) so I had to write my own driver for it.  
Minimal, but gets the job done. 


--John



Re: Amazing Perl 6

2009-05-29 Thread Patrick R. Michaud
On Fri, May 29, 2009 at 10:04:39AM -0700, Larry Wall wrote:
 On Fri, May 29, 2009 at 09:50:36AM -0700, yary wrote:
 : Show that much of the basics still work:
 :  my @x=('a' .. 'z'); @x[3,4]=qw(DeeDee Ramone);
 :   say @x.splice(2,4).join(',')
 : c,DeeDee,Ramone,f
 
 That qw is not a good example of what still works, since it is supposed
 to be interpreted as a qw subroutine (rakudo bug).  I recommend square
 brackets instead.

And Rakudo now correctly treats qw() like a function instead of
a quote:

  $ ./perl6
   say qw(DeeDee Ramone);
  Could not find non-existent sub Ramone
   say qw (DeeDee Ramone);
  DeeDeeRamone
   say qw[DeeDee Ramone];
  DeeDeeRamone
   

Thanks Larry!

Pm


Re: Amazing Perl 6

2009-05-29 Thread John M. Dlugosz

Buddha Buck blaisepascal-at-gmail.com |Perl 6| wrote:

In response to this thread, I activated the US International
keyboard layout, and once that's done theoretically one can get
Spanish style quote mark with RightAlt+[ and RightAlt+] like so: «
and ».

The questions which remain (for me, at least) is if (a) the symbols
survive in email, and (b) if they really are the proper marks for
Perl6.

  



Yes to both.  I see them fine, and they are the U+00AB and U+00BB 
characters.


Care to try ☃ ?  That's alt-meta-hyper-doublebucky-cokebottle.

--John


Re: Amazing Perl 6

2009-05-29 Thread John M. Dlugosz

Jon Lang dataweaver-at-gmail.com |Perl 6| wrote:

On Fri, May 29, 2009 at 6:52 AM, John Macdonald j...@perlwolf.com wrote:
  

Yep, I've done that.

But comparing the difference in effort between:

- press a key
- Google for a web page that has the right character set, cut, refocus, paste

means that I don't bother for the one or two weird characters
every few months that is my current Unicode usage.  If I were
working with Unicode frequently, it would be worth setting up
links and mechanisms, or learning the keyboard compose sequences
for frequently used characters.  I'm sure that there are many
people in a similar situation.



Agreed.  Given the frequency with which « and » come up in Perl 6, I'd
love to be able to have a simple keyboard shortcut that produces these
two characters.  Unfortunately, I am often stuck using a Windows
system when coding; and the easiest method that I have available to me
there (that I know of) is to pull up Character Map.

  
Windows:  see Tavultasoft's key mapper.  Free to use existing keyboard 
layouts, pro version needed to make your own.  It was awesome when 
writing stuff heavily-leaden with IPA characters.





Re: Amazing Perl 6

2009-05-29 Thread John M. Dlugosz

Buddha Buck blaisepascal-at-gmail.com |Perl 6| wrote:

On Fri, May 29, 2009 at 3:43 PM, John M. Dlugosz
2nb81l...@sneakemail.com wrote:
  

Buddha Buck blaisepascal-at-gmail.com |Perl 6| wrote:


In response to this thread, I activated the US International
keyboard layout, and once that's done theoretically one can get
Spanish style quote mark with RightAlt+[ and RightAlt+] like so: «
and ».

The questions which remain (for me, at least) is if (a) the symbols
survive in email, and (b) if they really are the proper marks for
Perl6.


  

Yes to both.  I see them fine, and they are the U+00AB and U+00BB
characters.

Care to try ☃ ?  That's alt-meta-hyper-doublebucky-cokebottle.



That's an eth, ð, right?  Hmm, doesn't look the same.  What is that?
  

--John


Copy and paste it from the message into a word processor or other 
program that lets you choose a font where it is not missing and make it 
very large so you can see the details.


Or see http://www.marco.org/83873337 for a large graphic in several fonts.

--John



Re: Amazing Perl 6

2009-05-29 Thread Larry Wall
On Fri, May 29, 2009 at 05:50:57PM -0500, John M. Dlugosz wrote:
 Copy and paste it from the message into a word processor or other  
 program that lets you choose a font where it is not missing and make it  
 very large so you can see the details.

 Or see http://www.marco.org/83873337 for a large graphic in several fonts.

Or feed it as an argument to this program, whereupon it will tell you
directly which character it is.

Larry

#!/usr/bin/perl -C

binmode STDOUT, :utf8;
$pat = @ARGV;
if (ord $pat  256) {
$pat = sprintf(%04x, ord $pat);
print That's $pat...\n;
$pat = '\b' . $pat . '\b';
}
elsif (ord $pat  128) {# arg in sneaky UTF-8
$pat = sprintf(%04x, unpack(U0U,$pat));
print That's $pat...\n;
$pat = '\b' . $pat . '\b';
}

@names = split /^/, do 'unicore/Name.pl';
for my $line (@names) {
$hex = hex($line);
$_ = chr($hex).\t.$line;
if (/$pat/io) {
print ' ' if /COMBINING/;
print;
}
}



Re: Amazing Perl 6

2009-05-29 Thread Timothy S. Nelson

On Fri, 29 May 2009, Jon Lang wrote:


On Fri, May 29, 2009 at 6:52 AM, John Macdonald j...@perlwolf.com wrote:

Yep, I've done that.

But comparing the difference in effort between:

- press a key
- Google for a web page that has the right character set, cut, refocus, paste

means that I don't bother for the one or two weird characters
every few months that is my current Unicode usage.  If I were
working with Unicode frequently, it would be worth setting up
links and mechanisms, or learning the keyboard compose sequences
for frequently used characters.  I'm sure that there are many
people in a similar situation.


Agreed.  Given the frequency with which « and » come up in Perl 6, I'd
love to be able to have a simple keyboard shortcut that produces these
two characters.  Unfortunately, I am often stuck using a Windows
system when coding; and the easiest method that I have available to me
there (that I know of) is to pull up Character Map.


There's some standard that says this is how to generate unicode:

1.  Hold down Ctrl+Shift
2.  Press U
3.  Type the hexadecimal for the unicode character
4.  Release Ctrl+Shift

	I'm under the impression that Windows supports this in some 
circumstances, and I know some Linux programs support it too.  Unfortunately 
my e-mail program (Pine) seems to have some trouble with unicode -- I may have 
to look at alternatives after 14 years of use :(.


HTH,


-
| Name: Tim Nelson | Because the Creator is,|
| E-mail: wayl...@wayland.id.au| I am   |
-

BEGIN GEEK CODE BLOCK
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- 
PE(+) Y+++ PGP-+++ R(+) !tv b++ DI D G+ e++ h! y-

-END GEEK CODE BLOCK-


Re: Amazing Perl 6

2009-05-29 Thread John M. Dlugosz
Ah yes, on the PC historically you hold down the ALT key and type the 
code with the numpad keys.





There's some standard that says this is how to generate unicode:

1.Hold down Ctrl+Shift
2.Press U
3.Type the hexadecimal for the unicode character
4.Release Ctrl+Shift

I'm under the impression that Windows supports this in some 
circumstances, and I know some Linux programs support it too.  
Unfortunately my e-mail program (Pine) seems to have some trouble with 
unicode -- I may have to look at alternatives after 14 years of use :(.


HTH,


-
| Name: Tim Nelson | Because the Creator is,|
| E-mail: wayl...@wayland.id.au| I am   |
-

BEGIN GEEK CODE BLOCK
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- PE(+) Y+++ 
PGP-+++ R(+) !tv b++ DI D G+ e++ h! y-

-END GEEK CODE BLOCK-




Re: Amazing Perl 6

2009-05-29 Thread Timothy S. Nelson

On Fri, 29 May 2009, John M. Dlugosz wrote:

Ah yes, on the PC historically you hold down the ALT key and type the code 
with the numpad keys.


	At least when I used it, this was a decimal, rather than hex number, 
and had to be preceded by a 0 (zero).


So if anyone is still on eg. Windows 98, this may be the way to go :).


-
| Name: Tim Nelson | Because the Creator is,|
| E-mail: wayl...@wayland.id.au| I am   |
-

BEGIN GEEK CODE BLOCK
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- 
PE(+) Y+++ PGP-+++ R(+) !tv b++ DI D G+ e++ h! y-

-END GEEK CODE BLOCK-



Re: Amazing Perl 6

2009-05-29 Thread Geoffrey Broadwell
Tim Nelson:
 There's some standard that says this is how to generate unicode:

 1.Hold down Ctrl+Shift
 2.Press U
 3.Type the hexadecimal for the unicode character
 4.Release Ctrl+Shift

This works under GNOME, which also has a variant that is a little
friendlier to the fingers (and probably also works better with various
accessibility changes to the shift keys):

1. Press Ctrl+Shift+U
2. Release; see 'underlined u' feedback
3. Type the hex for the Unicode character (leading 0's optional);
   hex digits continue showing underline feedback
4. Press Enter; underlined u and digits are replaced with final glyph


-'f




Re: Amazing Perl 6

2009-05-28 Thread Daniel Carrera

Hi Damian,

This is a really good list. Mind if I copy it / modify it and post it 
somewhere like my blog? One question:



* Compactness of expression + semi-infinite data structures:

@fib = 1,1...[+]# The entire Fibonacci sequence


Very impressive. That's even shorter than Haskell. What's [+] ? How 
does this work? In Haskell:


fibs = 1 : 1 : zipWith (+) fibs (tail fibs)



PS: A really mean, but very effective, way of emphasizing the ease,
expressiveness, compactness, and readability of Perl 6 code is to
take each of the examples and show the same thing written in
Java. ;-)


It might be appropriate to compare some examples with Ruby or Python.


Daniel.


Re: Amazing Perl 6

2009-05-28 Thread Damian Conway
Daniel Carrera wrote:

 This is a really good list. Mind if I copy it / modify it and post it
 somewhere like my blog?

That's fine.


 One question:

    * Compactness of expression + semi-infinite data structures:

       �...@fib = 1,1...[+]        # The entire Fibonacci sequence

 Very impressive. That's even shorter than Haskell. What's [+] ? How does
 this work?

The ... operator takes a list on the left and a generator sub (or block)
on the right. It creates a lazy list consisting initially of the left
operand. When the left operand runs out, the right operand is invoked to
generate extra values. The generator grabs as many existing values from
the end of the list as it needs arguments, then appends its result to the
end of the lazy list. Lather, rinse, repeat, as often as necessary.

In the Fibonacci example, the generator sub is [+], which is a
shorthand for infix:+. So, after 1,1 the generator grabs the last
two values (i.e. 1,1), adds them with infix:+, and puts 2 on the end
of the list. Next time a value is needed, infix:+ grabs the final
two list elements (now: 1,2), adds them, and appends 3 to the list.
Et cetera, et cetera.

For the use of ... to generate lists see: infix:..., the series operator
under http://perlcabal.org/syn/S03.html#List_infix_precedence. For the
[+] syntax, see http://perlcabal.org/syn/S03.html#Nesting_of_metaoperators


 PS: A really mean, but very effective, way of emphasizing the ease,
    expressiveness, compactness, and readability of Perl 6 code is to
    take each of the examples and show the same thing written in Java. ;-)

 It might be appropriate to compare some examples with Ruby or Python.

Only if the comparisons are suitably invidious. ;-)

Damian


Re: Amazing Perl 6

2009-05-28 Thread Jon Lang
On Thu, May 28, 2009 at 1:37 AM, Daniel Carrera
daniel.carr...@theingots.org wrote:
 Hi Damian,

 This is a really good list. Mind if I copy it / modify it and post it
 somewhere like my blog? One question:

    * Compactness of expression + semi-infinite data structures:

       �...@fib = 1,1...[+]        # The entire Fibonacci sequence

 Very impressive. That's even shorter than Haskell. What's [+] ? How does
 this work? In Haskell:

Start with the addition operator, '1 + 1'.  Apply the reducing
metaoperator to it so that it works syntactically like a function:
'[+] 1, 1'.  Instead of calling it, pass a code reference to it:
'[+]'.  The lazy list then uses that function to extend the list as
needed.

What I'm wondering is how the list knows to feed two items into '[+]'.
 While 'infix:+' must accept exactly two arguments, '[+]' can accept
an arbitrarily long (or short) list of arguments.

-- 
Jonathan Dataweaver Lang


Re: Amazing Perl 6

2009-05-28 Thread Damian Conway
Jon Lang suggested:

 Start with the addition operator, '1 + 1'.  Apply the reducing
 metaoperator to it so that it works syntactically like a function:
 '[+] 1, 1'.  Instead of calling it, pass a code reference to it:
 '[+]'.

No. [+] isn't the Code object for [+]; it's the Code object for infix:+.
See http://perlcabal.org/syn/S03.html#Nesting_of_metaoperators


 What I'm wondering is how the list knows to feed two items into '[+]'.
  While 'infix:+' must accept exactly two arguments, '[+]' can accept
 an arbitrarily long (or short) list of arguments.

And since [+] is infix:+, that's how it knows. :-)

Damian


Re: Amazing Perl 6

2009-05-28 Thread Mark J. Reed
So how is this:

 Any infix operator (except for non-associating operators) can be surrounded 
 by square brackets in term position to create a list operator
  that reduces using that operation:

reconciled with this:

 Any ordinary infix operator may be enclosed in square brackets with the same 
 meaning

?  And if [+] means infix:+, how do I refer to the Code of the
list operator [+]?


Re: Amazing Perl 6

2009-05-28 Thread Damian Conway
Mark J. Reed asked:

 So how is this:

 Any infix operator (except for non-associating operators) can be surrounded 
 by square brackets in term position to create a list operator
  that reduces using that operation:

 reconciled with this:

 Any ordinary infix operator may be enclosed in square brackets with the same 
 meaning

The first refers to (meta)operators encountered where a term is expected;
the second refers to operators encountered where an infix is expected
(i.e. after a term).


 ?  And if [+] means infix:+, how do I refer to the Code of the
 list operator [+]?

prefix:[+]

Damian


Re: Amazing Perl 6

2009-05-28 Thread Daniel Ruoso
Em Qui, 2009-05-28 às 21:36 +1000, Damian Conway escreveu:
 Mark J. Reed asked:
  ?  And if [+] means infix:+, how do I refer to the Code of the
  list operator [+]?
 prefix:[+]

Is that really? I mean... [ ] is a meta-operator, so

 [+] 1, 1, 2, 3

isn't a prefix, but a [ ] meta with + inside and the list as argument...

daniel



Re: Amazing Perl 6

2009-05-28 Thread Mark J. Reed
On Thu, May 28, 2009 at 8:43 AM, Daniel Ruoso dan...@ruoso.com wrote:
 Em Qui, 2009-05-28 às 21:36 +1000, Damian Conway escreveu:
 prefix:[+]

 Is that really? I mean... [ ] is a meta-operator, so

  [+] 1, 1, 2, 3

 isn't a prefix, but a [ ] meta with + inside and the list as argument...

The operator '[+]', which you get by applying the meta-operator
'[...]' to the infix binary operator '+', is a prefix list operator.

So that much makes sense.  But I still think the two different
meanings of square brackets in operators are going to confuse people.


-- 
Mark J. Reed markjr...@gmail.com


Re: Amazing Perl 6

2009-05-28 Thread John Macdonald
On Wed, May 27, 2009 at 05:42:58PM -0500, John M. Dlugosz wrote:
 Mark J. Reed markjreed-at-gmail.com |Perl 6| wrote:
 On Wed, May 27, 2009 at 6:05 PM, John M. Dlugosz
 2nb81l...@sneakemail.com wrote:
   
 And APL calls it |¨ (two little dots high up)
 

 Mr. MacDonald just said upthread that the APL reduce metaoperator was
 spelled /.  As in:

  +/1 2 3
  6

 So how does |¨ differ?


   

 Sorry, the two dots is APL's equivilent of the hyper operators, not the  
 reduction operators.  Easy to get those mixed up!

 For example, |1 2 3 ⍴¨ 10| would natively be written in Perl 6 as |10  
 »xx« (1,2,3)|.

 --John

Yes.  The full expression in raw APL for n! is:

*/in

(where i is the Greek letter iota - iotan is Perl's 1..$n).

Like many things in APL, having a 3-character combination of raw
operators to provide a function makes creating a special operator
unnecessary.  (Although, if I recall correctly, there were also raw
operators for combinatorial pick and choose, and factorial(n) is
the same as choose(n,n) [or pick(n,n) whichever is the one the
considers the order of the returned list to be significant] and
factorial was actually returned if there was only one operand
provided.)


Re: Amazing Perl 6

2009-05-28 Thread Uri Guttman
 DC == Damian Conway dam...@conway.org writes:

  DC * Grammars built into the language:

  DC grammar Expr::Arithetic {
  DC rule Expression { Mult ** $OP= + -}
  DC rule Mult   { Pow  ** $OP= * / %  }
  DC rule Pow{ Term ** $OP= ^  }

  DC token Term {
  DC Literal
  DC | '('  Expression  ')'
  DC }

  DC token Literal { [+\-]? \d+ [ \. \d+ ]?  }
  DC }

  DC * Grammar inheritance:

  DC grammar Expr::Algebraic is Expr::Arithetic {
  DC token Literal {
  DC alpha+
  DC | Expr::Arithetic::Literal
  DC }
  DC }

when i promote p6, the first and biggest thing i talk about
grammars. many of the other neat things (and damian listed a good bunch)
can be found in other langs or are nice but focused and small. p6
grammars are like nothing out there especially in any mainstream lang
today. and they are BIG in scope of what they can do. also they are very
accessible to newbies as they are based on the familiar regexes we all
use (and in almost all modern langs too). the mapping of grammar rules
to methods/subs and inheritance (which i generally despise but is
totally appropriate in grammars) is also amazing. now you can use
grammar libs and customize them as desired with little effort. before
this if you did have a grammar/parser (in any lang/system) you had to
learn its guts in detail before you dared to touch it. also grammars can
do dynamic things like build up a parsed data tree on the fly. you will
get what you expect (DWIM) with arrays of repeated grabbed sections
(properly nested as it follows your grammar). these are holy grails of
parsing and they come built in with incredible ease of use. note how
every other lang claims a perl5 compatible regex engine (and they lie as
none can do s///e among other things :). now with p6 they will never be
able to copy its grammars as it is a core part of p6 and not some regex
lib.

so you can talk about this amazing feature and be assured that the
audience will be amazed. :)

thanx,

uri

-- 
Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com --
-  Perl Code Review , Architecture, Development, Training, Support --
- Free Perl Training --- http://perlhunter.com/college.html -
-  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com -


Re: Amazing Perl 6

2009-05-28 Thread Larry Wall
On Thu, May 28, 2009 at 10:51:33AM -0400, John Macdonald wrote:
: Yes.  The full expression in raw APL for n! is:
: 
: */in
: 
: (where i is the Greek letter iota - iotan is Perl's 1..$n).

Only if the origin is 1.  This breaks under )ORIGIN 0.  cough $[ /cough

By the way, the assumption here is that everyone can process Unicode,
so it's fine to write */⍳n.  :)

Note that that's the APL iota U+2373, not any of the other 30 or so
iotas in Unicode.  :/  Well, okay, half of those have precomposed
accents, but still...

Larry


Re: Amazing Perl 6

2009-05-28 Thread Larry Wall
On Thu, May 28, 2009 at 09:43:58AM -0400, Mark J. Reed wrote:
: So that much makes sense.  But I still think the two different
: meanings of square brackets in operators are going to confuse people.

You're welcome to introduce more bracketing characters into ASCII.  :P

But seriously, this is one of those tagmemics things, where an A can
be *used* as a B without actually being one.  (For example, a noun
can be used as a verb.)  I think of [op] is the unambiguous name of
an infix operator (bare op is of course useful when unambiguous), and
[op] can be *used* as a prefix operator, or as the short name of the
function when prefixed by the noun marker .  Note that when you say

func()

you are, in fact, using the noun func as a verb.

Anyway, I suspect people are generally pretty good at differentiating
such things from the visual context.

Larry


Re: Amazing Perl 6

2009-05-28 Thread John Macdonald
On Thu, May 28, 2009 at 09:30:25AM -0700, Larry Wall wrote:
 On Thu, May 28, 2009 at 10:51:33AM -0400, John Macdonald wrote:
 : Yes.  The full expression in raw APL for n! is:
 : 
 : */in
 : 
 : (where i is the Greek letter iota - iotan is Perl's 1..$n).
 
 Only if the origin is 1.  This breaks under )ORIGIN 0.  cough $[ /cough

Yep.  That was why I was comfortable playing with $[ when it first came
along in early perl (wow, you can set the origin to any value, not just
0 or 1 - now that's progress).

 By the way, the assumption here is that everyone can process Unicode,
 so it's fine to write */⍳n.  :)

That's correct (in my case at least) if process means accept and
display properly.

However, the assumption fails if process is supposed to mean that
everyone is capable of generating Unicode in the messages that they
are writing.  I don't create non-English text often enough to have
it yet be useful to learn how.  (I'd just forget faster than I'd use
it and have to learn it again each time - but Perl 6 might just be
the tipping point to make learning Unicode composition worthwhile.)

 Note that that's the APL iota U+2373, not any of the other 30 or so
 iotas in Unicode.  :/  Well, okay, half of those have precomposed
 accents, but still...
 
 Larry


Re: Amazing Perl 6

2009-05-28 Thread Mark J. Reed
Since when are we limited to ASCII again? :)

If this is just a question of prefix vs infix telling you what [+] is
shorthand for, OK. But it seems there's still scope for conflict
between the two meanings of the square brackets.  I mean, prefix ops
can be used in reduce, too, right?

Tagentially related: why doesn't simple + or + work for what we're
currently spelling [+] (and which is more specifically spelled
infix:+)?



On 5/28/09, Larry Wall la...@wall.org wrote:
 On Thu, May 28, 2009 at 09:43:58AM -0400, Mark J. Reed wrote:
 : So that much makes sense.  But I still think the two different
 : meanings of square brackets in operators are going to confuse people.

 You're welcome to introduce more bracketing characters into ASCII.  :P

 But seriously, this is one of those tagmemics things, where an A can
 be *used* as a B without actually being one.  (For example, a noun
 can be used as a verb.)  I think of [op] is the unambiguous name of
 an infix operator (bare op is of course useful when unambiguous), and
 [op] can be *used* as a prefix operator, or as the short name of the
 function when prefixed by the noun marker .  Note that when you say

 func()

 you are, in fact, using the noun func as a verb.

 Anyway, I suspect people are generally pretty good at differentiating
 such things from the visual context.

 Larry


-- 
Sent from my mobile device

Mark J. Reed markjr...@gmail.com


Re: Amazing Perl 6

2009-05-28 Thread Larry Wall
On Thu, May 28, 2009 at 02:55:10PM -0400, Mark J. Reed wrote:
: Since when are we limited to ASCII again? :)

Well, we used some of Latin-1's bracket offerings, and people already
carp about that.  :)

: If this is just a question of prefix vs infix telling you what [+] is
: shorthand for, OK. But it seems there's still scope for conflict
: between the two meanings of the square brackets.  I mean, prefix ops
: can be used in reduce, too, right?

I will let you ponder the meaning of reduce a bit more, and the
relationship of that to the respective arity of infixes vs prefixes.
We already have hyper prefixes, if that's what you're thinking...

: Tagentially related: why doesn't simple + or + work for what we're
: currently spelling [+] (and which is more specifically spelled
: infix:+)?

Because it would conflict with twigils and such, not to mention
alphabetic infixes.  What would xx mean?

Larry


Re: Amazing Perl 6

2009-05-28 Thread Larry Wall
On Thu, May 28, 2009 at 02:55:10PM -0400, Mark J. Reed wrote:
: Tagentially related: why doesn't simple + or + work for what we're
: currently spelling [+] (and which is more specifically spelled
: infix:+)?

Oh, and why not +?  Mainly because we have lots of infix operators
containing  and , but none containing [ and ], so we use [...]
to disambiguate infixes already in things like [X]=.  So reusing
square brackets for [+] and [+] is deemed to be a good thing.

But also because foo would mean ($/foo).  [op] is a special
form, so it can get away with parsing it's innards specially,
whereas infix:op is not a special form, insofar as all adverbials
are parsed similarly, and infix:['op'] therefore requires quotes,
which is going the wrong direction when you're looking for a
shortcut.  People will get used to seeing [+] and thinking infix,
whereas + would always be causing double-takes by its similarity
to = and such.

Larry


Re: Amazing Perl 6

2009-05-28 Thread Mark J. Reed
On Thu, May 28, 2009 at 3:13 PM, Larry Wall la...@wall.org wrote:
 :  I mean, prefix ops can be used in reduce, too, right?

 I will let you ponder the meaning of reduce a bit more, and the
 relationship of that to the respective arity of infixes vs prefixes.

Well, infixes are necessarily binary, but while prefixes tend to be
slurpy, I was thinking one could also declare a prefix op with a
finite arity.  And does [...] only reduce if what's inside is an
operator?  How do you do a reduce using a plain old binary subroutine?

-- 
Mark J. Reed markjr...@gmail.com


Re: Amazing Perl 6

2009-05-28 Thread Larry Wall
On Thu, May 28, 2009 at 03:33:34PM -0400, Mark J. Reed wrote:
: On Thu, May 28, 2009 at 3:13 PM, Larry Wall la...@wall.org wrote:
:  :  I mean, prefix ops can be used in reduce, too, right?
: 
:  I will let you ponder the meaning of reduce a bit more, and the
:  relationship of that to the respective arity of infixes vs prefixes.
: 
: Well, infixes are necessarily binary, but while prefixes tend to be
: slurpy, I was thinking one could also declare a prefix op with a
: finite arity.

Well, sure, but we de-emphasize that arity when parsing anyway for
consistency.  All listop-y operators parse infinite args, even if
none of the candidates can handle them.

And if the prefix is declared slurpy, you'd just call it directly
on the arg list, I'd think, since it already has its own idea
of reduction built in.

: And does [...] only reduce if what's inside is an
: operator?

Yes, only operator, but including user-defined operators (unlike APL).

: How do you do a reduce using a plain old binary subroutine?

For the general form,

[+] @x

is equivalent to

reduce [+], @x

(Which is another good reason to keep the [+] form.)  Note that the
first arg to reduce is simply a noun, so forgetting the  as in:

reduce foo, @x

would be an error.  Unless foo returns something Callable, of course.
But the user probably meant:

reduce foo, @x.

So just as  turns the foo verb into a noun, it turns the [+] verb
into a noun.

Larry


Re: Amazing Perl 6

2009-05-28 Thread Damian Conway
Daniel Ruoso asked:

 prefix:[+]

 Is that really? I mean... [ ] is a meta-operator,

Sure. But once you []-meta an infix operator, you get a prefix operator.
See http://perlcabal.org/syn/S03.html#Reduction_operators, which states:

Any infix operator (except for non-associating operators) can
 be surrounded by square brackets in term position to create a
 list operator

and has an example of actually implementing the prefix:[+] operator.

Damian


Re: Amazing Perl 6

2009-05-28 Thread John M. Dlugosz

Mark J. Reed markjreed-at-gmail.com |Perl 6| wrote:


So that much makes sense.  But I still think the two different
meanings of square brackets in operators are going to confuse people.


  


I agree.  The previously quoted passages in the synopses are confusing, 
too, since it doesn't make the context clear.


If you find the shorthand too confusing, write it out as infix+ 
instead.  Perl can do solid software engineering as well as one-liners.


--John


Re: Amazing Perl 6

2009-05-28 Thread John M. Dlugosz

John Macdonald john-at-perlwolf.com |Perl 6| wrote:

However, the assumption fails if process is supposed to mean that
everyone is capable of generating Unicode in the messages that they
are writing.  I don't create non-English text often enough to have
it yet be useful to learn how.  (I'd just forget faster than I'd use
it and have to learn it again each time - but Perl 6 might just be
the tipping point to make learning Unicode composition worthwhile.)
  



Just copy/paste from another message or a web page.  Perhaps a web page 
designed for that purpose...


Re: Amazing Perl 6

2009-05-28 Thread Timothy S. Nelson

On Thu, 28 May 2009, John M. Dlugosz wrote:


John Macdonald john-at-perlwolf.com |Perl 6| wrote:

However, the assumption fails if process is supposed to mean that
everyone is capable of generating Unicode in the messages that they
are writing.  I don't create non-English text often enough to have
it yet be useful to learn how.  (I'd just forget faster than I'd use
it and have to learn it again each time - but Perl 6 might just be
the tipping point to make learning Unicode composition worthwhile.)


Just copy/paste from another message or a web page.  Perhaps a web page 
designed for that purpose...


Or:

setxkbmap -device $kbd-{ID} 'us(intl),gr(basic),il(biblical)' \
-option grp:switch,grp:scroll_toggle,grp_led:scroll,lv3:ralt_switch

(Worksforme on Fedora 10)

	Where the -device option chooses a keyboard (defaults to the core 
keyboard); if you need the number, use xinput list.


	That will let you type in English, Greek, and Hebrew, with lots of 
funny symbols accessible by pressing the right alt key, and using the scroll 
lock key to switch groups.


	Oh, actually, I thing the scroll lock stuff only works on my computer. 
But I'm sure you get the idea :).


	And the APL keyboard layout will appear in xorg soon, as soon as 
the xkeybaord-config exotic layouts issue is closed.


HTH,


-
| Name: Tim Nelson | Because the Creator is,|
| E-mail: wayl...@wayland.id.au| I am   |
-

BEGIN GEEK CODE BLOCK
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- 
PE(+) Y+++ PGP-+++ R(+) !tv b++ DI D G+ e++ h! y-

-END GEEK CODE BLOCK-



Re: Amazing Perl 6

2009-05-28 Thread Larry Wall
On Thu, May 28, 2009 at 08:06:14PM -0500, John M. Dlugosz wrote:
 Mark J. Reed markjreed-at-gmail.com |Perl 6| wrote:

 So that much makes sense.  But I still think the two different
 meanings of square brackets in operators are going to confuse people.


   

 I agree.  The previously quoted passages in the synopses are confusing,  
 too, since it doesn't make the context clear.

 If you find the shorthand too confusing, write it out as infix+  
 instead.  Perl can do solid software engineering as well as one-liners.

Which, of course, is not as solid as you think, since you left out the :
of the adverbial there... :)

So let's not make the mistake of thinking something longer is always
less confusing or more official.

Larry


Re: Amazing Perl 6

2009-05-27 Thread Daniel Carrera

Hi Daniel,

Sounds very interesting. Can you post slides? It'd be cool if the talk 
was taped, like the Google tech talks. Will it be in English? I don't 
speak Portuguese (I do speak Spanish and some German).



I'm planning to do a presentation to highlight the most impressive
aspects to Perl 6, in some way explaining why we are working on it for 9
years while still being excited about it.


Note: By trying to get things that are impressive, you don't want to do 
things that are so complicated that the audience gets the feeling that 
Perl 6 is too hard.


That said, lazy lists like 0..Inf is something that is both impressive 
and easy to understand.


You could try to think of things that are made easier or simpler by the 
new Perl 6. The only examples I can think of right now are:


sub foo($x,$y) { ... }

if $a  $b  $c { .. }

for @people - $dude { do something }
for %people.kv - $key, $value { do something }


Back on the subject of impressive, I really like lambdas:

$code = - $x { say $x }
$code(hello world);


I know this is not the approach you had in mind, but what do you think?

Daniel.


Re: Amazing Perl 6

2009-05-27 Thread Daniel Ruoso
Em Qua, 2009-05-27 às 18:46 +0200, Daniel Carrera escreveu:
 Hi Daniel,
Hi Daniel, :P

 Sounds very interesting. Can you post slides? It'd be cool if the talk 
 was taped, like the Google tech talks. Will it be in English? I don't 
 speak Portuguese (I do speak Spanish and some German).

It will be taped, as every talk in FISL is...

The talk will be in portuguese, as the audience of the forum is moslty
portuguese speaker, and submitting it in english would require being in
the main auditorium (the one with simultaneous translation) and getting
that approved would be harder...

But I guess subtitles can be made later... 

  I'm planning to do a presentation to highlight the most impressive
  aspects to Perl 6, in some way explaining why we are working on it for 9
  years while still being excited about it.
 Note: By trying to get things that are impressive, you don't want to do 
 things that are so complicated that the audience gets the feeling that 
 Perl 6 is too hard.

That's a thin line, but I'm aware of it...

 I know this is not the approach you had in mind, but what do you think?

Well, you really made me realize that I'm looking for things that make
me impressed, and probably I don't get impressed that easy nowadays ;)

daniel



Re: Amazing Perl 6

2009-05-27 Thread Mark J. Reed
 Well, you really made me realize that I'm looking for things that make
 me impressed, and probably I don't get impressed that easy nowadays ;)

Well, maybe you should relax your expectations.  People who haven't
been following P6 development for the last near-decade may be
impressed by stuff that seems trivial to veterans.  :)

I really like the factorial example on the wiki page.  That really
gets across the expressiveness of P6, without being too hard to
understand despite its brevity.  It's not often you find an elegant
yet non-recursive solution to that problem.

I do think captures are inherently impressive, but not easy to explain...


Re: Amazing Perl 6

2009-05-27 Thread Daniel Carrera

Daniel Ruoso wrote:

I know this is not the approach you had in mind, but what do you think?


Well, you really made me realize that I'm looking for things that make
me impressed, and probably I don't get impressed that easy nowadays ;)


I understand. Your experience with Perl 6 makes you harder to impress. 
So you are probably not impressed by the fact that you can do this:


if $a  $b  $c { ... }

But what if I told you that my university professor (while I was in 
university) chose to teach in Python because he saw that in Python you 
could do if a  b  c: and he thought oh! that's so cool!.


You know what you might want to do? Start with simple but neat examples 
that everyone can understand (such as the if statement) and work upward 
to more complex examples, so that your last example is something really 
impressive. I figure that if you work up to it gradually, the audience 
will not be intimidated when they see a large powerful example.


Daniel.


Re: Amazing Perl 6

2009-05-27 Thread Daniel Carrera

Mark J. Reed wrote:

I really like the factorial example on the wiki page.  That really
gets across the expressiveness of P6, without being too hard to
understand despite its brevity.


sub postfix:! { [*] 1..$^n }
say 5!;

WOW!!  That *IS* cool. Can you explain to me how it works? I figured out 
postfix: myself, but the rest is obscure to me.




I do think captures are inherently impressive, but not easy to explain...


Got a link?

Daniel.


Re: Amazing Perl 6

2009-05-27 Thread Mark J. Reed
On Wed, May 27, 2009 at 1:42 PM, Daniel Carrera
daniel.carr...@theingots.org wrote:
 sub postfix:! { [*] 1..$^n }
 say 5!;

 WOW!!  That *IS* cool. Can you explain to me how it works? I figured out
 postfix: myself, but the rest is obscure to me.

Key concepts:

1. placeholder variables.   The ^ in $^n means it's a placeholder: no
predeclaration required, and placeholders in an expression are
assigned the passed-in arguments in serial order.  (The sub could also
have been written more traditionally as  sub postfix:!($n) { [*]
1..$n } .)

2. the range operator .. :  $x..$y for integers $x and $y generates,
in list context, a list of the integers from $x to $y, inclusive.

3. the reduction meta-operator  [...] :   [OP](@list)  collects the
result of applying OP to the elements of the list in order.  That is,
assuming foo() is a binary sub,  [foo](1,2,3,4) =
foo(foo(foo(1,2),3),4).  So [+](@list) generates a sum of the listed
values, [*] generates their product, etc.

So, given the argument to !:

1. create a list of integers from 1 to that value (1..$^n)
2. multiply them all together ([*])

and of course a sub without an explicit return statement returns the
value of the last expression.





 I do think captures are inherently impressive, but not easy to explain...

 Got a link?

 Daniel.




-- 
Mark J. Reed markjr...@gmail.com


Re: Amazing Perl 6

2009-05-27 Thread Daniel Carrera

Daniel Carrera wrote:

sub postfix:! { [*] 1..$^n }
say 5!;

WOW!!  That *IS* cool. Can you explain to me how it works? I figured out 
postfix: myself, but the rest is obscure to me.


Here is another idea: Is it possible to declare a circumfix function 
that calculates the magnitude of a vector?


$magnitude = |@vector|;

You know how in math, two vertical bars are a standard notation for 
magnitude. Oh oh oh... is it possible to define a circumfix function for 
the dot product?  Something like:


$dot_product = @vector1,@vector2;

Is that possible? That would be uber-cool.

Daniel.


Re: Amazing Perl 6

2009-05-27 Thread Daniel Carrera

Mark J. Reed wrote:

3. the reduction meta-operator  [...] :   [OP](@list)  collects the
result of applying OP to the elements of the list in order.  That is,
assuming foo() is a binary sub,  [foo](1,2,3,4) =
foo(foo(foo(1,2),3),4).  So [+](@list) generates a sum of the listed
values, [*] generates their product, etc.


Wow... That's a foldl! In a functional language, that would be called a 
fold. It's very popular in Haskell.


I like that Perl 6 seems to be taking steps in the direction of 
functional languages. First lazy lists (0..Inf) and now a fold. :-D


Daniel.


Re: Amazing Perl 6

2009-05-27 Thread Mark J. Reed
On Wed, May 27, 2009 at 1:59 PM, Daniel Carrera 
daniel.carr...@theingots.org wrote:
 Wow... That's a foldl! In a functional language, that would be called a
 fold.

In Haskell it may be called fold (well, foldl and foldr), but the concept
has has a variety of names.  Two of the more common ones are reduce and
inject; I believe Perl6 chose reduce for consistency with the Perl5
List::Util module.  Common Lisp and Python also call it reduce:

(defun ! (n)
 (reduce #'* (loop for i from 1 to n collecting i)))


def fact(n):
 return reduce(lambda x,y: x*y, range(1,n+1))


While Ruby calls it inject.


def fact(n)
   (1..n).inject { |x,y| x*y }
end


Perl 6 has a lot of functional features.  IMO the nice thing about its
version of reduce is the way it's incorporated into the syntax as a
metaoperator.

--
Mark J. Reed markjr...@gmail.com


Re: Amazing Perl 6

2009-05-27 Thread Mark J. Reed
Note that of the examples given, only Perl 6 and Common Lisp do two things
that help immensely simplify the result:

1. reference the built-in * operator directly, without having to wrap it in
a lambda expression;
2. actually name the function !

The Lisp version suffers from the lack of a built-in range constructor.

On Wed, May 27, 2009 at 2:21 PM, Mark J. Reed markjr...@gmail.com wrote:


 In Haskell it may be called fold (well, foldl and foldr), but the concept
 has has a variety of names.  Two of the more common ones are reduce and
 inject; I believe Perl6 chose reduce for consistency with the Perl5
 List::Util module.  Common Lisp and Python also call it reduce:

 (defun ! (n)
  (reduce #'* (loop for i from 1 to n collecting i)))


 def fact(n):
  return reduce(lambda x,y: x*y, range(1,n+1))


 While Ruby calls it inject.


 def fact(n)
(1..n).inject { |x,y| x*y }
 end


 Perl 6 has a lot of functional features.  IMO the nice thing about its
 version of reduce is the way it's incorporated into the syntax as a
 metaoperator.

 --
 Mark J. Reed markjr...@gmail.com





-- 
Mark J. Reed markjr...@gmail.com


Re: Amazing Perl 6

2009-05-27 Thread John Macdonald
On Wed, May 27, 2009 at 02:21:40PM -0400, Mark J. Reed wrote:
 On Wed, May 27, 2009 at 1:59 PM, Daniel Carrera 
 daniel.carr...@theingots.org wrote:
  Wow... That's a foldl! In a functional language, that would be called a
  fold.
 
 In Haskell it may be called fold (well, foldl and foldr), but the concept
 has has a variety of names.  Two of the more common ones are reduce and
 inject; I believe Perl6 chose reduce for consistency with the Perl5
 List::Util module.  Common Lisp and Python also call it reduce:
 
 (defun ! (n)
  (reduce #'* (loop for i from 1 to n collecting i)))
 
 
 def fact(n):
  return reduce(lambda x,y: x*y, range(1,n+1))
 
 
 While Ruby calls it inject.
 
 
 def fact(n)
(1..n).inject { |x,y| x*y }
 end
 
 
 Perl 6 has a lot of functional features.  IMO the nice thing about its
 version of reduce is the way it's incorporated into the syntax as a
 metaoperator.

Historically, the name reduce was used (first?) in APL, which also
provided it as a meta-operator.  op/ would use op to reduce the array
on the right of the meta-operator.  (Although, in APL, it could be an
n-dimensional object, not necessarily a 2-dimensional array - the
reduce would compute an (n-1)-dimensional object from it.  This could
be used to generate row-sums and column sums.  APL was extremely terse,
you could compute almost anything in a single line - Perl golfing
afficionados have never really caught up, although with the addition
of Unicode operators Perl 6 could now go ahead.)


Re: Amazing Perl 6

2009-05-27 Thread John M. Dlugosz

Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote:


Please post impressive Perl 6 code snippets, we all know there are
several, and I really would like to give people some idea of why Perl 6
is so cool.

  



Of late, new languages have been created that are going backwards.  That 
is, they are regressing to a more primitive form.  C# is just Java with 
a different syntax.  Java is for people who can't handle the 
complexities of C++.  begin barbe voice Multiple inheritance is 
hard!/end.  So don't provide multiple inheritance, just rip it out, 
without replacing it with ANY other way to reuse implementation, so 
everyone uses copy/paste to build concrete classes that should have 
common code with others.


But... language science and research did not stop after OO was 
introduced.  Why don't new language use new, better ways of doing things?


Well, Perl 6 does.  That's what's cool about it, for me:  it looks 
toward newer ideas on a deep level, not just some shallow change but 
otherwise the same old stuff.


Look at Roles to showcase that.
Also, there is full delegation of methods with a terse syntax, useful 
for aggregating things that provide a desired interface.  And hopefully 
it will realize more of the ramifications behind allowing generic types, 
as my own research (see 
http://www.dlugosz.com/Perl6/web/isa-inheritance.html suggests.  It 
will embrace multi-core computers with implicit threading constructs.  
It's not just cool because its new features -- they are fundamental 
ideas that should have been with us for some time, but other languages 
refuse to accept.


--John



Re: Amazing Perl 6

2009-05-27 Thread Henry Baragar
On May 27, 2009 01:52:58 pm Mark J. Reed wrote:
 On Wed, May 27, 2009 at 1:42 PM, Daniel Carrera

 daniel.carr...@theingots.org wrote:
  sub postfix:! { [*] 1..$^n }
  say 5!;
 
  WOW!!  That *IS* cool. Can you explain to me how it works? I figured out
  postfix: myself, but the rest is obscure to me.

 Key concepts:

 1. placeholder variables.   The ^ in $^n means it's a placeholder: no
 predeclaration required, and placeholders in an expression are
 assigned the passed-in arguments in serial order.  (The sub could also
 have been written more traditionally as  sub postfix:!($n) { [*]
 1..$n } .)

 2. the range operator .. :  $x..$y for integers $x and $y generates,
 in list context, a list of the integers from $x to $y, inclusive.

 3. the reduction meta-operator  [...] :   [OP](@list)  collects the
 result of applying OP to the elements of the list in order.  That is,
 assuming foo() is a binary sub,  [foo](1,2,3,4) =
 foo(foo(foo(1,2),3),4).  So [+](@list) generates a sum of the listed
 values, [*] generates their product, etc.

 So, given the argument to !:
It might have been implied, but you kind of missed the discussion about the 
ability to add new operators (and how they relate to other operators).

To recap (slightly differently) there are several impressive features that are 
easier to explain and can be part of the build up to the factorial example:
Placeholder variables: non-declared and descriptive
Ranger operators: not so impressive and inherited from perl5 (etc.)
The reduction meta-operator [...]: nice syntax and no need to provide a 
identity/seed element
A side discussion of other interesting meta-operators
User defined operators:  overloading and novel mechanism of declaring 
precedence (looser, tighter, etc.)
Finally, a simple slide where the factorial definition takes up the whole slide 
and let the audience have a few moments of silence to let them figure it out 
and to start to really appreciate the expressiveness/impressiveness of perl6
Henry


 1. create a list of integers from 1 to that value (1..$^n)
 2. multiply them all together ([*])

 and of course a sub without an explicit return statement returns the
 value of the last expression.

  I do think captures are inherently impressive, but not easy to
  explain...
 
  Got a link?
 
  Daniel.

-- 

Henry Baragar
Instantiated Software
416-907-8454 x42


Re: Amazing Perl 6

2009-05-27 Thread Daniel Carrera

Mark J. Reed wrote:
In Haskell it may be called fold (well, foldl and foldr), but the 
concept has has a variety of names.  Two of the more common ones are 
reduce and inject;


The terms I've seen are fold and reduce. The fold term is not just 
from Haskell. I've seen it elsewhere. If you had said inject I 
wouldn't have known what you meant.


Daniel.


Re: Amazing Perl 6

2009-05-27 Thread Daniel Carrera

Mark J. Reed wrote:

Note that of the examples given, only Perl 6 and Common Lisp do two things
that help immensely simplify the result:

1. reference the built-in * operator directly, without having to wrap it in
a lambda expression;
2. actually name the function !


Yes, very neat. Haskell does that too, but I don't know if you can make 
the function a postfix in Haskell.


Daniel.


Re: Amazing Perl 6

2009-05-27 Thread Mark J. Reed
On Wed, May 27, 2009 at 3:38 PM, Daniel Carrera 
daniel.carr...@theingots.org wrote:

 The terms I've seen are fold and reduce. The fold term is not just
 from Haskell. I've seen it elsewhere. If you had said inject I wouldn't
 have known what you meant.


The name inject comes from Smalltalk, where you :inject the initial value
:into the operation, whose arguments are the accumulator and the new item
(it has no fold-1 variant).

Wikipedia mentions accumulate (C++) and compress (no example cited) as
additional names.

In Perl6, I assume [...] automatically folds left on left-associative
operators and right on right-associative ones?

-- 
Mark J. Reed markjr...@gmail.com


Re: Amazing Perl 6

2009-05-27 Thread Larry Wall
On Wed, May 27, 2009 at 07:56:42PM +0200, Daniel Carrera wrote:
 Here is another idea: Is it possible to declare a circumfix function  
 that calculates the magnitude of a vector?

 $magnitude = |@vector|;

 You know how in math, two vertical bars are a standard notation for  
 magnitude. Oh oh oh... is it possible to define a circumfix function for  
 the dot product?  Something like:

 $dot_product = @vector1,@vector2;

 Is that possible? That would be uber-cool.

The problem with that is the presence of an existing prefix:|
operator.  One could fake it with a postfix:| macro that rewrites
the AST produces by the prefix, except no one implements macros yet.
But circumfix openers have to share longest-token space with prefixes.

You could maybe use broken bar instead, circumfix:¦ ¦.

Larry


Re: Amazing Perl 6

2009-05-27 Thread Larry Wall
Sorry, only answered half of your question.

On Wed, May 27, 2009 at 07:56:42PM +0200, Daniel Carrera wrote:
 Oh oh oh... is it possible to define a circumfix function for  
 the dot product?  Something like:

 $dot_product = @vector1,@vector2;

 Is that possible? That would be uber-cool.

More likely just use

sub infix:· (@a,@b) { ... }
$dot_product = @vector1 · @vector2;

Or some such.

Larry


Re: Amazing Perl 6

2009-05-27 Thread Daniel Carrera

Larry Wall wrote:

$dot_product = @vector1,@vector2;

Is that possible? That would be uber-cool.


More likely just use

sub infix:· (@a,@b) { ... }
$dot_product = @vector1 · @vector2;


Thanks.

And for Daniel R. and other observers, how about this:

# Courtesy of Larry
sub infix:· (@a,@b) { [+] @a »*« @b }

my @vector1 = (1,2,3);
my @vector2 = (2,3,4);
say @vector1 · @vector2;


I think that's really nifty. So you can talk about Hyper operators and 
then show the dot product. What do you think?


Daniel.


Re: Amazing Perl 6

2009-05-27 Thread John M. Dlugosz

Mark J. Reed markjreed-at-gmail.com |Perl 6| wrote:

Well, you really made me realize that I'm looking for things that make
me impressed, and probably I don't get impressed that easy nowadays ;)



Well, maybe you should relax your expectations.  People who haven't
been following P6 development for the last near-decade may be
impressed by stuff that seems trivial to veterans.  :)

I really like the factorial example on the wiki page.  That really
gets across the expressiveness of P6, without being too hard to
understand despite its brevity.  It's not often you find an elegant
yet non-recursive solution to that problem.

I do think captures are inherently impressive, but not easy to explain...

  


captures are inherently impressive, but not easy to explain...  Since 
nobody's done so yet, I suppose so.


As for fun and expressive, have you seen my APL and Lisp inspired 
stuff?  In the latter, I found out for myself just how expressive it is 
in a deep appreciation I didn't have before.  In particular, why is the 
Perl 6 version even shorter than Lisp?  Because it has the fully 
overarching self-descriptive features, but lets you leave out excess 
verbage.


Re: Amazing Perl 6

2009-05-27 Thread John M. Dlugosz


Mark J. Reed markjreed-at-gmail.com |Perl 6| wrote:

In Haskell it may be called fold (well, foldl and foldr), but the concept
has has a variety of names.  Two of the more common ones are reduce and
inject; I believe Perl6 chose reduce for consistency with the Perl5
List::Util module.  Common Lisp and Python also call it reduce:

(defun ! (n)
 (reduce #'* (loop for i from 1 to n collecting i)))


def fact(n):
 return reduce(lambda x,y: x*y, range(1,n+1))


While Ruby calls it inject.


def fact(n)
   (1..n).inject { |x,y| x*y }
end


  


And APL calls it |¨ (two little dots high up)
|


Re: Amazing Perl 6

2009-05-27 Thread John M. Dlugosz

Mark J. Reed markjreed-at-gmail.com |Perl 6| wrote:

On Wed, May 27, 2009 at 6:05 PM, John M. Dlugosz
2nb81l...@sneakemail.com wrote:
  

And APL calls it |¨ (two little dots high up)



Mr. MacDonald just said upthread that the APL reduce metaoperator was
spelled /.  As in:

 +/1 2 3
 6

So how does |¨ differ?


  


Sorry, the two dots is APL's equivilent of the hyper operators, not the 
reduction operators.  Easy to get those mixed up!


For example, |1 2 3 ⍴¨ 10| would natively be written in Perl 6 as |10 
»xx« (1,2,3)|.


--John


Re: Amazing Perl 6

2009-05-27 Thread Damian Conway
Here are a few of my favourite Perl 6 selling points:

* Compactness of expression:

say 'Hello, World!';

* Compactness of expression + semi-infinite data structures:

@fib = 1,1...[+]# The entire Fibonacci sequence

* Junctions make comparisons much more natural:

if $dice_sum == 7 | 11 {
say 'Natural!'
}
elsif $dice_sum == 2 | 3 | 12 {
say 'Craps!'
}

* Given/when takes that even further:

given $dice_sum {
when 7 | 11 { say 'Natural!' }
when 2 | 3 | 12 { say 'Craps!' }
}

* Junctions + n-ary comparison help too:

if 0  all(@coefficients) = 1 {
say 'Coefficients are already normalized.';
}

* Junctive comparisons + the max operator:

if any(@new_values)  all(@existing_values) {
$upper_limit = [max] @new_values;
}

* .invert and .push makes hashes (especially hoa's) vastly more useful
(and .perl makes debugging vastly easier):

my %comments =
perl6 = Amazing Revolutionary,
perl5 = Essential Amazing,
perl4 = Classic,
perl1 = Classic;

my %epithets;
%epithets.push(%comments.invert);

say %comments.perl;
say %epithets.perl;

* Unicode source and data overthrows US cultural hegemony!
(oh, and Hinrik has the coolest name in the entire Perl community :-)

my @recepción;
my $Gruß  = 'olá'
my $óvoµa = 'Hinrik Örn Sigurðsson';

push @recepción, $Gruß, $óvoµa!;


* Unary method call + topicalization simplifies multiple operations
on objects:

for @parcels {
.address;
.weigh;
.ship;
while .shipping {
.fold;
.spindle;
.mutilate;
}
.deliver;
}

* Subtypes make typing far more precise (and hence more useful):

my $filename of Str where /\w**8 '.' \w**3/;

my $octet of Int where { 0 = $^value = 255 }



* Command-line parsing using standard language features:

sub MAIN ($text, Bool :f($foo), Str :B($bar), *...@files)
{
...
}

# Can then be invoked as:

 my_prog.p6 -f  -Bbaz  'two words'  file1 file2 etc


* Grammars built into the language:

grammar Expr::Arithetic {
rule Expression { Mult ** $OP= + -}
rule Mult   { Pow  ** $OP= * / %  }
rule Pow{ Term ** $OP= ^  }

token Term {
Literal
| '('  Expression  ')'
}

token Literal { [+\-]? \d+ [ \. \d+ ]?  }
}

* Grammar inheritance:

grammar Expr::Algebraic is Expr::Arithetic {
token Literal {
alpha+
| Expr::Arithetic::Literal
}
}

* Only perl can parse Perl 5 but Even Perl 6 can parse Perl 6:

given $source_code {
$parsetree = m:keepall/Perl::prog/;
}


And that's without even mentioning all the new OO features, multiple
dispatch, roles, delegation, macros, etc., etc. The problem with demo-
ing the awesomeness of Perl 6 is always running out of demo time before
running out of demo-able awesomeness.

Damian

PS: A really mean, but very effective, way of emphasizing the ease,
expressiveness, compactness, and readability of Perl 6 code is to
take each of the examples and show the same thing written in
Java. ;-)


Re: Amazing Perl 6

2009-05-27 Thread Mark J. Reed
On Wed, May 27, 2009 at 2:39 PM, John Macdonald j...@perlwolf.com wrote:
 Historically, the name reduce was used (first?) in APL, which also
 provided it as a meta-operator.  op/ would use op to reduce the array
 on the right of the meta-operator.

It's quite possible that APL was the first use of the term reduce in
that sense - I know that (reduce) didn't make it into LISP until
relatively late, possibly not until Common Lisp.

 APL was extremely terse,  you could compute almost anything in a single line 
- Perl golfing
 afficionados have never really caught up, although with the addition
 of Unicode operators Perl 6 could now go ahead.)

Perhaps Perl 6 should not aspire to the expressiveness of APL. :)  As
nice as it is that you can write Conway's Life in a one-liner(*), I
think that a little verbosity now and then is a good thing for
legibility

-- 
Mark J. Reed markjr...@gmail.com


(*) life ←{↑1 ω⌵.^3 4=+/,‾1 0 1◦.ϕ⊂ω}

I haven't tested it, but the above will allegedly compute the next
generation from a Life configuration (input and output represented as
a matrix of 1s and 0s).