Re: Language Design: 'special casing' of split()? (i.e. .split performs concomitant .join? )

2020-10-10 Thread Tobias Boege
On Sun, 11 Oct 2020, Tobias Boege wrote: > On Sat, 10 Oct 2020, William Michels via perl6-users wrote: > > then proceed to process the function call. As it is my understanding that > > Raku incorporates a lot of different programming paradigms (imperative, > > object-orie

Re: Language Design: 'special casing' of split()? (i.e. .split performs concomitant .join? )

2020-10-10 Thread Tobias Boege
On Sat, 10 Oct 2020, William Michels via perl6-users wrote: > So I guess the first question I have is whether the 'auto-joining' of array > elements is specc'ed or not. > I did not find anything that explicitly requires @array.split() to force @array into a string, but there are tests in

Re: liens and :chomp question

2020-08-30 Thread Tobias Boege
On Sun, 30 Aug 2020, ToddAndMargo via perl6-users wrote: > >- You are calling .lines on the value of .IO.open which is an > > IO::Handle. IO::Handle.lines does not take a named argument > > :chomp, so passing one is useless. > > That explains it. > > Bu: >

Re: liens and :chomp question

2020-08-30 Thread Tobias Boege
On Sat, 29 Aug 2020, ToddAndMargo via perl6-users wrote: > Hi All, > > I am trying to figure out how to use line with :$chomp. > Now what am I doing wrong? > > > $ alias p6 > alias p6='perl6 -e' > > $ p6 'say "Lines.txt".IO.open.lines(:chomp)[3,2];' > (Line 3 Line 2) > > $ p6 'say

Re: lines :$nl-in question

2020-08-29 Thread Tobias Boege
On Fri, 28 Aug 2020, ToddAndMargo via perl6-users wrote: >https://docs.raku.org/type/IO::Path#method_lines > >(IO::Path) method lines > >Defined as: > >method lines(IO::Path:D: :$chomp = True, :$enc = 'utf8', :$nl-in = > ["\x0A", "\r\n"], |c --> Seq:D) > >Opens the

Re: Raku User's Survey 2020 out now....

2020-08-27 Thread Tobias Boege
On Thu, 27 Aug 2020, ToddAndMargo via perl6-users wrote: > To pick out particular lines: >$ cat Lines.txt | raku -e '.say for lines()[3,2,5]' >Line 3 >Line 2 >Line 5 > > If it is, it is buried somewhere. > > And what goes inside the ()? That may seem like a dumb > remark

Re: Seq whitespace sensitivity? (was Re: print particular lines question)

2020-08-26 Thread Tobias Boege
On Wed, 26 Aug 2020, Tobias Boege wrote: > Observe: > > > 1 ...^ 20 > (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19) > > > 1 ... ^20 # actually C«1 ... (0..19)» > (1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19) > > The documentation [1] sta

Re: Seq whitespace sensitivity? (was Re: print particular lines question)

2020-08-26 Thread Tobias Boege
On Wed, 26 Aug 2020, William Michels via perl6-users wrote: > > They can be pretty great, especially when combined with the magic op= > > operators that (in essence) know about identity elements. I've done a few > > challenges on the Code Golf Stackexchange site where I wanted an infinite > >

Re: Combining multiple "is..." traits into one?

2020-08-11 Thread Tobias Boege
On Wed, 12 Aug 2020, Stuart Hungerford wrote: > Hi, > > I'm working with roles where the mixing-in classes and roles need to > have some mixin-specific notion of equality. So I have an Equality > role that can also be > mixed in as needed: > > role Equality { > method equal(Equality:D) of

Re: subs and the type system

2020-07-20 Thread Tobias Boege
On Mon, 20 Jul 2020, Gianni Ceccarelli wrote: > Aside: > > ``(sub (Int $ --> Int) {}) ~~ Walkable`` is false, because > ``:(Int $ --> Int) ~~ :(Numeric $ --> Numeric)`` is false, which is > correct because function subtypes should be contravariant in the parameter > types and covariant in the

Re: subs and the type system

2020-07-20 Thread Tobias Boege
On Mon, 20 Jul 2020, Theo van den Heuvel wrote: > Hi gurus, > > after looking at the documentation on Sub, Signature and the raku type > system I find myself unable to constrain the types of functions in the way I > think I need. > > The situation: I have a function, let's call in 'walker',

Re: root cubic

2020-07-09 Thread Tobias Boege
On Thu, 09 Jul 2020, Tobias Boege wrote: > Now, there are effective ways to represent algebraic numbers like 9 ** (1/3) > in such a way that you can do arithmetic with them, but I'm not aware of any > implementation of that available to Raku. For someone with enough tuits, > I think

Re: root cubic

2020-07-09 Thread Tobias Boege
On Thu, 09 Jul 2020, Aureliano Guedes wrote: > Hi all, > > A quick question. > > This is expected? > > raku -e 'say 9 ** (1/3)' > 2.080083823051904 > > > Why do I'm asking this? > I know about the computational floating problem and I also know that the > Raku deal with rational whenever it is

Re: why so different

2020-06-22 Thread Tobias Boege
On Mon, 22 Jun 2020, Aureliano Guedes wrote: > Thank you for the clarification. > > There is a method to set Rat precision at the scope of the program to apply > to all *.Rat() cases? > I don't know, based on a quick search in the documentation, of any global setting. The hacky solution would

Re: why so different

2020-06-22 Thread Tobias Boege
On Mon, 22 Jun 2020, Aureliano Guedes wrote: > Hi all, > > First, I'm naive in Raku. Then let's go to my question. > > I'm trying to figure out why we got so different results here: > > > e.Rat()**(pi.Rat()*i) > -0.9902-1.3942922582021257e-07i > > e**(pi*i) >

Re: junctions and parenthesis

2020-06-22 Thread Tobias Boege
On Mon, 22 Jun 2020, Elizabeth Mattijsen wrote: > BEGIN trait_mod:(, :tighter(:<*>)); > > comes to mind, but that doesn't seem to do the trick. > My guess: tighter and looser are only consulted by the parser in contexts where 'any' was recognized as an *operator*.

Re: junctions and parenthesis

2020-06-22 Thread Tobias Boege
On Mon, 22 Jun 2020, Joseph Brenner wrote: > Patrick R. Michaud wrote: > > > The "any" function is just like any other function taking an arbitrary list > > of arguments (including user-defined functions). As such it parses with > > lower precedence than comparison operators -- so "eq" binds

Re: I need help sorting a list

2020-05-24 Thread Tobias Boege
On Sun, 24 May 2020, Elizabeth Mattijsen wrote: > Hmmm... it appears we need to numerify the match to get numeric comparison > semantics, so we put a "+" before the match: > > $ raku -e 'my @x=.sort: { +m/ \d+ $/ }; for @x { say $_; > }' > a1 > a2 > a5 > a123 > a133 > So I think this would be

Re: I need help sorting a list

2020-05-24 Thread Tobias Boege
On Sun, 24 May 2020, ToddAndMargo via perl6-users wrote: > On 2020-05-24 02:24, Elizabeth Mattijsen wrote: > > dd .sort: { m/ \d+ $/ } > > > > Hi Elizabeth, > > This seems to work: > >$ raku -e 'dd .sort: { m/ \d+ $/ };' >("a5", "a6", "a33", "a111").Seq > > > But I can't figure out

Re: sqrt and Buf question

2020-05-14 Thread Tobias Boege
On Thu, 14 May 2020, ToddAndMargo via perl6-users wrote: > Hi All, > > 1) how do I get 40 or more digits out of sqrt? > Meaningful digits? Not possible as sqrt uses limited precision. I think the IEEE 754 doubles that I would suspect to be used internally are capped way below 40 significant

Re: NativeCall questions

2020-05-08 Thread Tobias Boege
On Fri, 08 May 2020, David Santiago wrote: > I also noticed that although my data string is defined as > CArray[uint8], when i loop through the array, the values are signed > ints: > > say $_ for $ed.data[0..10]; > > output: > > -98 There is an old open bug report about this:

Re: subst :g and captures in the replacement

2020-04-19 Thread Tobias Boege
On Sun, 19 Apr 2020, yary wrote: > How would one do s/(.+),(.+)/$1,$0/ using .subst ? > -y You can pass a code block as the second argument which assembles the replacement text. The block is evaluated anew for every substitution and it has access to the latest captures: say .subst(/(.*) ','

Re: subst :g and captures in the replacement

2020-04-19 Thread Tobias Boege
On Sun, 19 Apr 2020, yary wrote: > Question from today's Raku meetup. This works in a way I expect > > > 'fosdffgg'.subst(/f+/,"( "~ * ~" )", :g); > ( f )osd( ff )gg > > This one, $0 gets the single f each time > > > 'fosdffgg'.subst(/(f+)/,"( $0 )", :g); > ( f )osd( f )gg > > Bug or

Re: regex objects as hash keys

2020-04-05 Thread Tobias Boege
On Sun, 05 Apr 2020, Joseph Brenner wrote: > I find in Raku that (as expected) I can use an object as a hash key: > > class Rutabaga { method color { say "purple (and white)"; } } > > my $obj = Rutabaga.new > my %vegeout; > %vegeout{ $obj } = "this works"; > > And for something

Re: What is operand 152 and 160?

2020-03-31 Thread Tobias Boege
On Tue, 31 Mar 2020, ToddAndMargo via perl6-users wrote: > Hi All, > > Windows 10-1909 Pro > > raku -v > This is Rakudo version 2020.01 built on MoarVM version > 2020.01.1 implementing Perl 6.d. > > Running my program I get this at a call to > a sub in a module: > > operand type 160 does

Re: irrational nubmer?

2020-02-26 Thread Tobias Boege
On Wed, 26 Feb 2020, ToddAndMargo via perl6-users wrote: > > > $ p6 'say (99/70).base-repeating();' > > > (1.4 142857) > > > > > > means that 142857 also repeats (it does not), but > > > that it is best it can figure out with the precision > > > it has? > > > > > > > What are you talking about?

Re: irrational nubmer?

2020-02-26 Thread Tobias Boege
On Wed, 26 Feb 2020, Todd Chester via perl6-users wrote: > Hi Tobias, > > I am confused as to as to what you mean by numerator and > denominator. > Rational numbers can always be written as the ratio of two integers: a/b with b non-zero. One calls a the numerator and b the denominator. In Raku

Re: irrational nubmer?

2020-02-20 Thread Tobias Boege
On Thu, 20 Feb 2020, ToddAndMargo via perl6-users wrote: > > > On Fri, 21 Feb 2020 at 13:31, ToddAndMargo via perl6-users > > > mailto:perl6-users@perl.org>> wrote: > > > > > > $ perl6 -e 'say sqrt(2).base-repeating();' > > > No such method 'base-repeating' for invocant of type 'Num' > >

Re: irrational nubmer?

2020-02-20 Thread Tobias Boege
On Wed, 19 Feb 2020, Paul Procacci wrote: > >> Is there a test to see if a number is irrational > There is no such thing as an irrational number in computing. > > Surely there are "close approximations", but that's the best any computer > language can currently do. > It all depends on

Re: bytes are used in an UInt/Int?

2020-02-03 Thread Tobias Boege
On Mon, 03 Feb 2020, ToddAndMargo via perl6-users wrote: > Hi All, > > Did Larry put a sneaky way to tell how many bytes > a UInt/Int is using? > The number of bits required to store an Int is, for positive numbers, the same as the index of their most significant bit, which is available via

Re: Hash Constraints w/in subset's

2020-02-01 Thread Tobias Boege
On Sat, 01 Feb 2020, Paul Procacci wrote: > Hey ladies/gents, > > How would one go about defining a subset of a Hash who's key's and values > are both constrained by something > > I've read https://docs.perl6.org/type/Hash and it does make mention of > constraining keys and values, but not

Re: stolen uint's

2020-01-29 Thread Tobias Boege
On Tue, 28 Jan 2020, ToddAndMargo via perl6-users wrote: > This all came up when I tried to match > > RegSetValueExW( > _In_ HKEY hKey, > _In_opt_ LPCWSTR lpValueName, > _Reserved_ DWORD Reserved, > _In_ DWORD dwType, >

Re: Range on Subsets

2020-01-28 Thread Tobias Boege
On Tue, 28 Jan 2020, Simon Proctor wrote: > So some recent conversations covered the Range method on numeric types like > Int > > So Int.Range gives the range of valid values -Inf^..^Inf which is neat. > > Then I thought I'd try UInt.Range and got 0..^Inf > > Ah Ha! Thinks I. I have a plan.

Re: stolen uint's

2020-01-25 Thread Tobias Boege
On Sat, 25 Jan 2020, ToddAndMargo via perl6-users wrote: > Hi All, > > Anyone have a workaround to my stolen uint's? > > > constant DWORD := uint32; > (uint32) > > > subset StrOrDword where Str | DWORD; > (StrOrDword) > > > sub x( StrOrDword $item ) { > * say "$item is a " ~ $item.^name;

Re: troubles with with base(2)

2020-01-20 Thread Tobias Boege
On Mon, 20 Jan 2020, ToddAndMargo via perl6-users wrote: > Hi All, > > Now what am I doing wrong? > > my $v = 0b00101101 ^ 0b1001; say $v.base(2); > one(101101, 1001) > > It should be > 100100 > Please examine the output you get. Does the spurious "one" in there not make you

Re: my first two doc issues

2020-01-19 Thread Tobias Boege
On Sun, 19 Jan 2020, ToddAndMargo via perl6-users wrote: > RFE: Please add the following examples to routine +^ > https://github.com/Raku/doc/issues/3177 > > Now I wait and see what kind of reception I get. It > will be nice to contribute to the docs, rather than > just always griping about them

Re: Ping JJ: string literals

2020-01-19 Thread Tobias Boege
On Sat, 18 Jan 2020, ToddAndMargo via perl6-users wrote: > > > Would you be so kind to post this as an issue in the documentation, so > > we can pick up on it? > > > > Thanks! > > > > JJ > > Would you mind posting back the link to it, so I can > get on the following list?

Re: problems with xor

2020-01-18 Thread Tobias Boege
On Fri, 17 Jan 2020, ToddAndMargo via perl6-users wrote: > Hi All, > > https://docs.raku.org/routine/+$CIRCUMFLEX_ACCENT > > (Operators) infix +^§ > > multi sub infix:<+^>($a, $b --> Int:D) > > Integer bitwise XOR operator: Coerces both arguments to Int and does a > bitwise XOR (exclusive OR)

Re: Ping JJ: string literals

2020-01-18 Thread Tobias Boege
On Sat, 18 Jan 2020, JJ Merelo wrote: > The example works perfectly, and it does because it's a string literal > which is already 0 terminated. Let's use this code instead of the one that > I used in my other mail about this (which you probably didn't read anyway): > > 8< 8< 8< > > What does

Re: Cardinals

2020-01-02 Thread Tobias Boege
On Thu, 02 Jan 2020, ToddAndMargo via perl6-users wrote: > Hi All, > > “He who asks is a fool for five minutes, but he who > does not ask remains a fool forever.” > ― Mark Twain > > This would be my five minutes. I will live. > > How do I do a 32 bit unsigned integer (cardinal)?

Re: play with raku and autobiographical numbers

2019-12-31 Thread Tobias Boege
On Tue, 31 Dec 2019, Marc Chantreux wrote: > hello, > > 2020 describes itself as it is composed by > > 2 0 > 0 1 > 2 2 > 0 3 > > perfect golf excuse! I have : > > sub is_autobiographic (\x) { > my \s = x.Str; > my @r = s.comb; > my %appearance_of; >

Re: square root question

2019-12-15 Thread Tobias Boege
On Sat, 14 Dec 2019, ToddAndMargo wrote: > What am I doing wrong here? > > > multi prefix:<√> (Cool:D $x) { $x.sqrt } > :<√> > > > say √2 > ===SORRY!=== > Argument to "say" seems to be malformed > --> say⏏ √2 > Bogus postfix If this is inside the REPL, it's not your fault. It's a known

Re: about 'use v6.d'

2019-12-13 Thread Tobias Boege
On Fri, 13 Dec 2019, Brad Gilbert wrote: > There should probably be a way to require a minimum version of the compiler. > > use rakudo v2019.07; > As I understand it, this would do something quite different from `use v6`, which is probably your point(?). A single Raku compiler would strive

Re: My keeper on "contains"

2019-12-09 Thread Tobias Boege
On Mon, 09 Dec 2019, perl6-users-h...@perl.org wrote: > Date: Sun, 8 Dec 2019 17:45:22 -0800 > From: ToddAndMargo via perl6-users > To: perl6-users > Subject: My keeper on "contains" > > 8< ... > > Case insensitive contains: > $ p6 'if "2018 Jul 7".fc.contains( "jul".fc ) {say "Yes";}' >