Re: odd and even

2018-05-04 Thread ToddAndMargo

On 04/30/2018 02:34 AM, Thomas Klausner wrote:

and presumably also some online tutorial.


Trouble is when you search for Perl 5 stuff, you get STOMPED with
Perl 5 hits.

I agree with your on the reference remark.  I they
were to use more practical examples, it would help.


Re: odd and even

2018-05-04 Thread Thomas Klausner
Hi!

On Mon, Apr 30, 2018 at 02:23:44AM -0700, ToddAndMargo wrote:
 
> So, the main issue I have with the docs is that they
> "seem" to be written as a refresher for an advanced use
> and not as a trainer for a newbie.

I guess that's because the docs are meant as a reference, and not as a 
tutorial. AFAIK there are several good Perl6 tutorial-style books 
available, and presumably also some online tutorial.

Greetings,
domm

-- 
#!/usr/bin/perl  http://domm.plix.at
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}


Re: odd and even

2018-05-02 Thread yary
It's all hyperbole, circular reasoning with bits hidden behind
ellipsis... parboiled lexiconical sections.
-y


On Tue, May 1, 2018 at 10:04 PM, Brandon Allbery  wrote:
> On Tue, May 1, 2018 at 9:17 PM, Larry Wall  wrote:
>>
>> On Tue, May 01, 2018 at 01:43:44AM -0700, ToddAndMargo wrote:
>> : The worst thing I had problems with in Perl was folks telling it
>> : was "Lexiconical".  What?  I wish they would have also said "which
>> : means Perl figures out your variables type on the fly, so you don't
>> : have to type cast everything".
>>
>> Just so that nobody overgeneralizes this into a general Perl meme, let
>> me point out that to the best of my recollection (which ain't as good
>> as it used to was), I've never heard the term "lexiconical" used that
>> way (or any way, really), and I'd be completely weirded out if someone
>> used it that way, since dynamic typing (figuring out types on the fly)
>> has almost nothing to do with either lexicons or lexical scoping.
>
>
> I've heard it, and considered it someone being too clever for their own
> good. Or anyone else's.
>
> --
> brandon s allbery kf8nh   sine nomine associates
> allber...@gmail.com  ballb...@sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: odd and even

2018-05-01 Thread Brandon Allbery
On Tue, May 1, 2018 at 9:17 PM, Larry Wall  wrote:

> On Tue, May 01, 2018 at 01:43:44AM -0700, ToddAndMargo wrote:
> : The worst thing I had problems with in Perl was folks telling it
> : was "Lexiconical".  What?  I wish they would have also said "which
> : means Perl figures out your variables type on the fly, so you don't
> : have to type cast everything".
>
> Just so that nobody overgeneralizes this into a general Perl meme, let
> me point out that to the best of my recollection (which ain't as good
> as it used to was), I've never heard the term "lexiconical" used that
> way (or any way, really), and I'd be completely weirded out if someone
> used it that way, since dynamic typing (figuring out types on the fly)
> has almost nothing to do with either lexicons or lexical scoping.
>

I've heard it, and considered it someone being too clever for their own
good. Or anyone else's.

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: odd and even

2018-05-01 Thread ToddAndMargo

On 05/01/2018 06:17 PM, Larry Wall wrote:

On Tue, May 01, 2018 at 01:43:44AM -0700, ToddAndMargo wrote:
: The worst thing I had problems with in Perl was folks telling it
: was "Lexiconical".  What?  I wish they would have also said "which
: means Perl figures out your variables type on the fly, so you don't
: have to type cast everything".

Just so that nobody overgeneralizes this into a general Perl meme, let
me point out that to the best of my recollection (which ain't as good
as it used to was), I've never heard the term "lexiconical" used that
way (or any way, really), and I'd be completely weirded out if someone
used it that way, since dynamic typing (figuring out types on the fly)
has almost nothing to do with either lexicons or lexical scoping.

So I suspect someone has subjected you to a rather idiosyncratic
term and definition there...

Larry



Hi Larry,

I hear it from the grouches over on comp.lang.perl.misc
all the time.  But then again, they seem to think Perl6
is Java.

I LOVE the new subroutine declarations in Perl6.  Wonderful
clean up.  Thank you!

-T


--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: odd and even

2018-05-01 Thread Brent Laabs
Yeah, that lexiconic section sounded a bit hyperbolic.

On Tue, May 1, 2018 at 6:17 PM, Larry Wall  wrote:

> On Tue, May 01, 2018 at 01:43:44AM -0700, ToddAndMargo wrote:
> : The worst thing I had problems with in Perl was folks telling it
> : was "Lexiconical".  What?  I wish they would have also said "which
> : means Perl figures out your variables type on the fly, so you don't
> : have to type cast everything".
>
> Just so that nobody overgeneralizes this into a general Perl meme, let
> me point out that to the best of my recollection (which ain't as good
> as it used to was), I've never heard the term "lexiconical" used that
> way (or any way, really), and I'd be completely weirded out if someone
> used it that way, since dynamic typing (figuring out types on the fly)
> has almost nothing to do with either lexicons or lexical scoping.
>
> So I suspect someone has subjected you to a rather idiosyncratic
> term and definition there...
>
> Larry
>


Re: odd and even

2018-05-01 Thread Larry Wall
On Tue, May 01, 2018 at 01:43:44AM -0700, ToddAndMargo wrote:
: The worst thing I had problems with in Perl was folks telling it
: was "Lexiconical".  What?  I wish they would have also said "which
: means Perl figures out your variables type on the fly, so you don't
: have to type cast everything".

Just so that nobody overgeneralizes this into a general Perl meme, let
me point out that to the best of my recollection (which ain't as good
as it used to was), I've never heard the term "lexiconical" used that
way (or any way, really), and I'd be completely weirded out if someone
used it that way, since dynamic typing (figuring out types on the fly)
has almost nothing to do with either lexicons or lexical scoping.

So I suspect someone has subjected you to a rather idiosyncratic
term and definition there...

Larry


Re: odd and even

2018-05-01 Thread Parrot Raiser
The result of a modulus-2 is always going to be 0 or 1, so if you can
put the "even" and "odd" results in a 2 -element array, using it as a
subscript would be a way to achieve the outcome.

On 5/1/18, ToddAndMargo  wrote:
> On 04/30/2018 06:47 AM, Elizabeth Mattijsen wrote:
>
>> Perhaps this is a simpler solution:
>>
>>  for split( "\n", $ClipStr ) -> $evenline, $oddline? {
>>  say “Purple $evenline”;
>>  say “Green $_” with $oddline;
>>  }
>
> Two lines at a time.  Fascinating!   Thank you!
>


Re: odd and even

2018-05-01 Thread ToddAndMargo

On 04/30/2018 06:47 AM, Elizabeth Mattijsen wrote:


Perhaps this is a simpler solution:

 for split( "\n", $ClipStr ) -> $evenline, $oddline? {
 say “Purple $evenline”;
 say “Green $_” with $oddline;
 }


Two lines at a time.  Fascinating!   Thank you!


Re: odd and even

2018-05-01 Thread ToddAndMargo

Please remember that I have about 1/100 of your skill when you
explain things to me.  (For instance, I have no clue what
`subset` is or how to use it.)

-T




On 04/30/2018 06:52 AM, Theo van den Heuvel wrote:
> Hi Todd,
>
> different people have different ways of learning things. Diving into the
> documentation isn't ideal for all of us. I find the book by Laurent
> Rosenfeld, "Think Perl 6", O'Reilly, extremely helpful in addition to
> the docs.
>
> My problem is that I am working with many and quite different
> programming languages simultaneously and that drives me nuts on a
> regular basis. Well, not much to be done about that, I'm afraid.
>
> happy perling,
>

Hi Theo,

Ya, no fooling.

I have been programming for about 35 years.  I found I can not learn
from a "course".  My head hits the table.  I can't stay awake.
I have to dive in and program something I need and takes notes
as to how to do things.

I came from Pascal & Modula 2.  What a cultural shift to Perl.
Perl fix my needs perfectly.  Did a lot of bash script and batch
files too.  Batch is truly the programming language from hxxl.
Never did learn "C".  It has only proved an issue when I want to
make system calls.

The worst thing I had problems with in Perl was folks telling it
was "Lexiconical".  What?  I wish they would have also said "which
means Perl figures out your variables type on the fly, so you don't have 
to type cast everything".


-T


Re: odd and even

2018-04-30 Thread Theo van den Heuvel

Hi Todd,

different people have different ways of learning things. Diving into the 
documentation isn't ideal for all of us. I find the book by Laurent 
Rosenfeld, "Think Perl 6", O'Reilly, extremely helpful in addition to 
the docs.


My problem is that I am working with many and quite different 
programming languages simultaneously and that drives me nuts on a 
regular basis. Well, not much to be done about that, I'm afraid.


happy perling,




Please remember that I have about 1/100 of your skill when you
explain things to me.  (For instance, I have no clue what
`subset` is or how to use it.)

-T


--
Theo van den Heuvel
Van den Heuvel HLT Consultancy


Re: odd and even

2018-04-30 Thread Elizabeth Mattijsen

> On 30 Apr 2018, at 15:12, ToddAndMargo  wrote:
> 
> On 04/30/2018 05:44 AM, Elizabeth Mattijsen wrote:
>>> On 30 Apr 2018, at 12:43, ToddAndMargo  wrote:
>>> 
>>> 
>>>> Am 30.04.2018 um 08:47 schrieb ToddAndMargo:
>>>>> Hi All,
>>>>> 
>>>>> I know it would only take me 25 seconds to write one,
>>>>> but do we have an odd and even function build in?
>>>>> 
>>>>> 
>>>>> Many thanks,
>>>>> -T
>>>>> 
>>>>> $ perl6 -e 'my $x=3; say $x.odd;'
>>>>> No such method 'odd' for invocant of type 'Int'. Did you mean 'ord'?
>>>>>   in block  at -e line 1
>>>>> 
>>>>> $ perl6 -e 'my $x=3; say $x.even;'
>>>>> No such method 'even' for invocant of type 'Int'
>>>>>   in block  at -e line 1
>>> 
>>> On 04/30/2018 02:05 AM, Martin Barth wrote:
>>>> Are you aware of the %% operator?
>>>> 
>>>> $var %% 2 checks wether it is dividable by 2.
>>>> 
>>>> 
>>> 
>>> No I was not.  Thank you!
>>> 
>>> I was just going to do a
>>> 
>>> sub  odd( $Num ) { return $Num % 2; }
>>> sub even( $Num ) { return not $Num.odd; }
>> If you create this sub to do value checking, then maybe this approach is 
>> better for you:
>> subset EvenInt of Int where * %% 2;  # all the even Ints
>> subset OddInt of Int where * !%% 2;  # all the odd Ints
>> # works
>> my EvenInt $x = 42;
>> # dies with: Type check failed in assignment to $y; expected EvenInt but 
>> got Int (42)
>> my OddInt  $y = 42;
>> Liz
> 
> I don't get it.  Why would I want to do this?   I only want to know if
> an integer is odd or even.  What am I missing?
> 
> For example, I just coded this:
> 
>sub odd( $Num ) { return $Num % 2; }
> 
>for split( "\n", $ClipStr ).kv -> $LineNum, $Line {
>if odd $LineNum
>   { $PartsStr ~= ''; }  # Green
> else  { $PartsStr ~= ''; }  # Purple
>...
>}

Perhaps this is a simpler solution:

for split( "\n", $ClipStr ) -> $evenline, $oddline? {
say “Purple $evenline”;
say “Green $_” with $oddline;
}

Note that in this case if you have a odd total number of lines, you can have 
$oddline come is as a type object.  So you need the ? in the signature of the 
block and the check with “with” in the code (which evaluates to True if the 
value is *not* a type object, and it also sets $_ for you then).


Hope this helps



Re: odd and even

2018-04-30 Thread Elizabeth Mattijsen

> On 30 Apr 2018, at 15:12, ToddAndMargo  wrote:
> 
> On 04/30/2018 05:44 AM, Elizabeth Mattijsen wrote:
>>> On 30 Apr 2018, at 12:43, ToddAndMargo  wrote:
>>> 
>>> 
>>>> Am 30.04.2018 um 08:47 schrieb ToddAndMargo:
>>>>> Hi All,
>>>>> 
>>>>> I know it would only take me 25 seconds to write one,
>>>>> but do we have an odd and even function build in?
>>>>> 
>>>>> 
>>>>> Many thanks,
>>>>> -T
>>>>> 
>>>>> $ perl6 -e 'my $x=3; say $x.odd;'
>>>>> No such method 'odd' for invocant of type 'Int'. Did you mean 'ord'?
>>>>>   in block  at -e line 1
>>>>> 
>>>>> $ perl6 -e 'my $x=3; say $x.even;'
>>>>> No such method 'even' for invocant of type 'Int'
>>>>>   in block  at -e line 1
>>> 
>>> On 04/30/2018 02:05 AM, Martin Barth wrote:
>>>> Are you aware of the %% operator?
>>>> 
>>>> $var %% 2 checks wether it is dividable by 2.
>>>> 
>>>> 
>>> 
>>> No I was not.  Thank you!
>>> 
>>> I was just going to do a
>>> 
>>> sub  odd( $Num ) { return $Num % 2; }
>>> sub even( $Num ) { return not $Num.odd; }
>> If you create this sub to do value checking, then maybe this approach is 
>> better for you:
>> subset EvenInt of Int where * %% 2;  # all the even Ints
>> subset OddInt of Int where * !%% 2;  # all the odd Ints
>> # works
>> my EvenInt $x = 42;
>> # dies with: Type check failed in assignment to $y; expected EvenInt but 
>> got Int (42)
>> my OddInt  $y = 42;
>> Liz
> 
> I don't get it.  Why would I want to do this?   I only want to know if
> an integer is odd or even.  What am I missing?
> 
> For example, I just coded this:
> 
>sub odd( $Num ) { return $Num % 2; }
> 
>for split( "\n", $ClipStr ).kv -> $LineNum, $Line {

>if odd $LineNum
>   { $PartsStr ~= ''; }  # Green
> else  { $PartsStr ~= ''; }  # Purple
>...
>}
> 
> It allows me to alternate the color for odd and even lines.
> 
> Please remember that I have about 1/100 of your skill when you
> explain things to me.  (For instance, I have no clue what
> `subset` is or how to use it.)

A subset creates a new Type (like Int) from a base type (such as Int) and 
narrows down the condition that is acceptable for it.

https://docs.perl6.org/language/typesystem#index-entry-subset-subset


Re: odd and even

2018-04-30 Thread ToddAndMargo

On 04/30/2018 05:44 AM, Elizabeth Mattijsen wrote:



On 30 Apr 2018, at 12:43, ToddAndMargo  wrote:



Am 30.04.2018 um 08:47 schrieb ToddAndMargo:

Hi All,

I know it would only take me 25 seconds to write one,
but do we have an odd and even function build in?


Many thanks,
-T

$ perl6 -e 'my $x=3; say $x.odd;'
No such method 'odd' for invocant of type 'Int'. Did you mean 'ord'?
   in block  at -e line 1

$ perl6 -e 'my $x=3; say $x.even;'
No such method 'even' for invocant of type 'Int'
   in block  at -e line 1


On 04/30/2018 02:05 AM, Martin Barth wrote:

Are you aware of the %% operator?

$var %% 2 checks wether it is dividable by 2.




No I was not.  Thank you!

I was just going to do a

 sub  odd( $Num ) { return $Num % 2; }
 sub even( $Num ) { return not $Num.odd; }


If you create this sub to do value checking, then maybe this approach is better 
for you:

 subset EvenInt of Int where * %% 2;  # all the even Ints
 subset OddInt of Int where * !%% 2;  # all the odd Ints

 # works
 my EvenInt $x = 42;

 # dies with: Type check failed in assignment to $y; expected EvenInt but 
got Int (42)
 my OddInt  $y = 42;




Liz



I don't get it.  Why would I want to do this?   I only want to know if
an integer is odd or even.  What am I missing?

For example, I just coded this:

sub odd( $Num ) { return $Num % 2; }

for split( "\n", $ClipStr ).kv -> $LineNum, $Line {
if odd $LineNum
   { $PartsStr ~= ''; }  # Green
         else  { $PartsStr ~= ''; }  # Purple
...
}

It allows me to alternate the color for odd and even lines.

Please remember that I have about 1/100 of your skill when you
explain things to me.  (For instance, I have no clue what
`subset` is or how to use it.)

-T


Re: odd and even

2018-04-30 Thread Elizabeth Mattijsen

> On 30 Apr 2018, at 12:43, ToddAndMargo  wrote:
> 
> 
>> Am 30.04.2018 um 08:47 schrieb ToddAndMargo:
>>> Hi All,
>>> 
>>> I know it would only take me 25 seconds to write one,
>>> but do we have an odd and even function build in?
>>> 
>>> 
>>> Many thanks,
>>> -T
>>> 
>>> $ perl6 -e 'my $x=3; say $x.odd;'
>>> No such method 'odd' for invocant of type 'Int'. Did you mean 'ord'?
>>>   in block  at -e line 1
>>> 
>>> $ perl6 -e 'my $x=3; say $x.even;'
>>> No such method 'even' for invocant of type 'Int'
>>>   in block  at -e line 1
> 
> On 04/30/2018 02:05 AM, Martin Barth wrote:
> > Are you aware of the %% operator?
> >
> > $var %% 2 checks wether it is dividable by 2.
> >
> >
> 
> No I was not.  Thank you!
> 
> I was just going to do a
> 
> sub  odd( $Num ) { return $Num % 2; }
> sub even( $Num ) { return not $Num.odd; }

If you create this sub to do value checking, then maybe this approach is better 
for you:

subset EvenInt of Int where * %% 2;  # all the even Ints
subset OddInt of Int where * !%% 2;  # all the odd Ints

# works
my EvenInt $x = 42;

# dies with: Type check failed in assignment to $y; expected EvenInt but 
got Int (42)
my OddInt  $y = 42;




Liz

Re: odd and even

2018-04-30 Thread ToddAndMargo



Am 30.04.2018 um 08:47 schrieb ToddAndMargo:

Hi All,

I know it would only take me 25 seconds to write one,
but do we have an odd and even function build in?


Many thanks,
-T

$ perl6 -e 'my $x=3; say $x.odd;'
No such method 'odd' for invocant of type 'Int'. Did you mean 'ord'?
  in block  at -e line 1

$ perl6 -e 'my $x=3; say $x.even;'
No such method 'even' for invocant of type 'Int'
  in block  at -e line 1


On 04/30/2018 02:05 AM, Martin Barth wrote:
> Are you aware of the %% operator?
>
> $var %% 2 checks wether it is dividable by 2.
>
>

No I was not.  Thank you!

I was just going to do a

 sub  odd( $Num ) { return $Num % 2; }
 sub even( $Num ) { return not $Num.odd; }

-T
--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: odd and even

2018-04-30 Thread Martin Barth

Are you aware of the %% operator?

$var %% 2 checks wether it is dividable by 2.


Am 30.04.2018 um 08:47 schrieb ToddAndMargo:

Hi All,

I know it would only take me 25 seconds to write one,
but do we have an odd and even function build in?


Many thanks,
-T

$ perl6 -e 'my $x=3; say $x.odd;'
No such method 'odd' for invocant of type 'Int'. Did you mean 'ord'?
  in block  at -e line 1

$ perl6 -e 'my $x=3; say $x.even;'
No such method 'even' for invocant of type 'Int'
  in block  at -e line 1


Re: odd and even

2018-04-30 Thread ToddAndMargo


El lun., 30 abr. 2018 a las 9:46, ToddAndMargo (<mailto:toddandma...@zoho.com>>) escribió:


On 04/30/2018 12:04 AM, JJ Merelo wrote:
 > Check out the docs.perl6.org <http://docs.perl6.org>
<http://docs.perl6.org> page... And no, we
 > don't.

Love the docs.  Not always really helpful though.


On 04/30/2018 01:10 AM, JJ Merelo wrote:
> When they are not, please raise an issue. We'll try to solve it ASAP.
>

Hi JJ,

It is mainly the way the functions are written up.  They give theory
and then a few bad examples.

For instance:
https://docs.perl6.org/routine/split

multi subsplit(  Str:D $delimiter, Str(Cool) $input, $limit = 
Inf, :$k, :$v, :$kv, :$p, :$skip-empty)


which is theory and means absolutely nothing to me.
Please don't try to explain it either.  I won't remember
ten minutes after you tell me.  Maybe if I have been writing
for five years in Perl, it would be different.

And for the examples:

say split(/<[;,]>/, "a;b;c,d").perl;

Without an explanation, it means, again, nothing.  What
the heck is ".perl" and what in the world is "/<[;,]>/?
Again, please do not try to explain.

And real fun search for "perl" in the docs.
You only get about 325,732 hots.  (This is why
I asked about odd and even.)

So, the main issue I have with the docs is that they
"seem" to be written as a refresher for an advanced use
and not as a trainer for a newbie.

What I have been doing is 1) do the the docs, 2) write
up a `perl -e` to see if I can get it to work, 3) if not,
get on the chat line, give the url I looked at and my
one liner.  After I get it all figured out, I write myself
a keeper explaining how it works.

Just an aside, the guys on the chat line are "extraordinary"
fellows.

-T

p.s. I have reported bugs in the docs before.


Re: odd and even

2018-04-30 Thread JJ Merelo
When they are not, please raise an issue. We'll try to solve it ASAP.

El lun., 30 abr. 2018 a las 9:46, ToddAndMargo ()
escribió:

> On 04/30/2018 12:04 AM, JJ Merelo wrote:
> > Check out the docs.perl6.org  page... And no, we
> > don't.
>
> Love the docs.  Not always really helpful though.
>


-- 
JJ


Re: odd and even

2018-04-30 Thread ToddAndMargo

On 04/30/2018 12:04 AM, JJ Merelo wrote:
Check out the docs.perl6.org  page... And no, we 
don't.


Love the docs.  Not always really helpful though.


Re: odd and even

2018-04-30 Thread JJ Merelo
Check out the docs.perl6.org page... And no, we don't.

El lun., 30 abr. 2018 a las 8:48, ToddAndMargo ()
escribió:

> Hi All,
>
> I know it would only take me 25 seconds to write one,
> but do we have an odd and even function build in?
>
>
> Many thanks,
> -T
>
> $ perl6 -e 'my $x=3; say $x.odd;'
> No such method 'odd' for invocant of type 'Int'. Did you mean 'ord'?
>in block  at -e line 1
>
> $ perl6 -e 'my $x=3; say $x.even;'
> No such method 'even' for invocant of type 'Int'
>in block  at -e line 1
>


-- 
JJ


odd and even

2018-04-29 Thread ToddAndMargo

Hi All,

I know it would only take me 25 seconds to write one,
but do we have an odd and even function build in?


Many thanks,
-T

$ perl6 -e 'my $x=3; say $x.odd;'
No such method 'odd' for invocant of type 'Int'. Did you mean 'ord'?
  in block  at -e line 1

$ perl6 -e 'my $x=3; say $x.even;'
No such method 'even' for invocant of type 'Int'
  in block  at -e line 1