Re: My first functional perl6 program

2006-08-23 Thread Luke Palmer
On 8/23/06, Larry Wall <[EMAIL PROTECTED]> wrote: Yes, that should work eventually, given that hypers are supposed to stop after the longest *finite* sequence. Shudder xx * What the hell does that mean!? Let me posit this: @a = 0..42; @b = list_of_twin_primes(); (@a >>=><< @b).lengt

Re: clarifying the spec for 'ref'

2006-08-23 Thread Luke Palmer
On 8/23/06, Larry Wall <[EMAIL PROTECTED]> wrote: you really want: if $a ~~ Array { and that also matches Array::Const, assuming it's derived from Array. Well, actually Array would be a subtype of Array::Const, not t'other way round. That is a little bit disconcerting, because when you s

Re: My first functional perl6 program

2006-08-23 Thread Mark J. Reed
On 8/23/06, Larry Wall <[EMAIL PROTECTED]> wrote: Strange, this works for me: $_ = "foo"; say .uc FOO Maybe that was fixed in 6.2.12, then. I'm still running 6.2.11, and at least on Cygwin, I get this: $ pugs -e '$_ = "foo"; say .uc' $ No output. And if I try .trans: $ pugs -e '$_

Re: My first functional perl6 program

2006-08-23 Thread Larry Wall
On Wed, Aug 23, 2006 at 06:39:52PM -0400, Mark J. Reed wrote: : It does sadden me somewhat that the say() requires the parens (or an : explicit $_ etc). But I'll live. :) Strange, this works for me: $_ = "foo"; say .uc FOO Seems to work with .uc() as well. Larry

Re: My first functional perl6 program

2006-08-23 Thread Larry Wall
On Wed, Aug 23, 2006 at 06:49:06PM -0400, Mark J. Reed wrote: : On 8/23/06, Mark J. Reed <[EMAIL PROTECTED]> wrote: : >my %trans = ('a'..'z') »=>« ('?' xx 26); : : Also, correct me if I'm wrong, but I should theoretically be able to : use xx * there, thus creating a lazily-evaluated infinitely-lon

Re: clarifying the spec for 'ref'

2006-08-23 Thread Larry Wall
On Wed, Aug 23, 2006 at 06:20:55PM -0400, Mark Stosberg wrote: : I noticed in pugs, 'ref' does not return 'HASH' and 'ARRAY' as Perl5 : does, but returns values including 'Hash', 'Array' and 'Array::Const'. Well, first of all, ref is going away entirely, since there's no such thing as a reference

Re: My first functional perl6 program

2006-08-23 Thread Mark J. Reed
On 8/23/06, Mark J. Reed <[EMAIL PROTECTED]> wrote: my %trans = ('a'..'z') »=>« ('?' xx 26); Also, correct me if I'm wrong, but I should theoretically be able to use xx * there, thus creating a lazily-evaluated infinitely-long list of question marks? -- Mark J. Reed <[EMAIL PROTECTED]>

My first functional perl6 program

2006-08-23 Thread Mark J. Reed
To get my feet wet, I thought I'd translate my silly little cryptogram helper. It turned out like this: #!/usr/local/bin/pugs #== # Braindead cryptogram assistant with hard-coded key. #--

Re: Pair of lists => list of pairs?

2006-08-23 Thread Larry Wall
On Wed, Aug 23, 2006 at 03:19:22PM -0700, Larry Wall wrote: : But I'd still probably use a hyper-fatarrow for this case rather than : relying on interleaving. Another reason for preferring hyper is that it makes promises about parallelizability, whereas the zip/each solutions would tend to assume

Re: Pair of lists => list of pairs?

2006-08-23 Thread Mark J. Reed
> Reduce operators only turn infix into list operators. What you really > want here is a hyper-fatarrow: > > my %h = @k »=>« @v; Ah, right. Silly me. I got hyper and reduce confused. Thanks! Gaal pointed out using zip. What would be the difference then between a hyper-fatarrow an

clarifying the spec for 'ref'

2006-08-23 Thread Mark Stosberg
I noticed in pugs, 'ref' does not return 'HASH' and 'ARRAY' as Perl5 does, but returns values including 'Hash', 'Array' and 'Array::Const'. I don't find meaningful mentions of 'HASH' and 'ARRAY' by grep'ing docs/Perl6 (or even "ref"!), so I wanted to check in here about the meaningfulness of this

Re: Pair of lists => list of pairs?

2006-08-23 Thread Larry Wall
On Thu, Aug 24, 2006 at 12:51:04AM +0300, Gaal Yahas wrote: : On Wed, Aug 23, 2006 at 05:43:48PM -0400, Mark J. Reed wrote: : > But is there an easy way in Perl6 to do it all in one go? Should this work? : > : > my %h = @k [=>] @v; : : You want a zip: : : my %h = @k ¥ @v; : my %h = @k Y @v;

Re: Pair of lists => list of pairs?

2006-08-23 Thread Michael Snoyman
: my %h; : [EMAIL PROTECTED] = @v; : : But is there an easy way in Perl6 to do it all in one go? Should this work? : : my %h = @k [=>] @v; Reduce operators only turn infix into list operators. What you really want here is a hyper-fatarrow: my %h = @k »=>« @v; Gaal pointed out using zip

Re: Pair of lists => list of pairs?

2006-08-23 Thread Juerd
Mark J. Reed skribis 2006-08-23 17:43 (-0400): > But is there an easy way in Perl6 to do it all in one go? Should this work? > my %h = @k [=>] @v; Hyper is not [], but >><<. And >>=><< works perfectly in Pugs, and does exactly what you describe. [] is for reduction, and is prefix: [+] 1,2,3 Ju

Re: Pair of lists => list of pairs?

2006-08-23 Thread Larry Wall
On Wed, Aug 23, 2006 at 05:43:48PM -0400, Mark J. Reed wrote: : Suppose I have two arrays @k and @v and I want to declare and initialize a : hash %h such that %h.keys eqv @k and %h.values eqv @v. : : I could use a direct translation of the P5 idiom: : : my %h; : [EMAIL PROTECTED] = @v; : : But i

Re: Pair of lists => list of pairs?

2006-08-23 Thread Gaal Yahas
On Wed, Aug 23, 2006 at 05:43:48PM -0400, Mark J. Reed wrote: > But is there an easy way in Perl6 to do it all in one go? Should this work? > > my %h = @k [=>] @v; You want a zip: my %h = @k ¥ @v; my %h = @k Y @v; # ASCII fallback my %h = zip(@k, @v); # or maybe zip(@k; @v) this week? --

Pair of lists => list of pairs?

2006-08-23 Thread Mark J. Reed
Suppose I have two arrays @k and @v and I want to declare and initialize a hash %h such that %h.keys eqv @k and %h.values eqv @v. I could use a direct translation of the P5 idiom: my %h; [EMAIL PROTECTED] = @v; But is there an easy way in Perl6 to do it all in one go? Should this work? my %h