perl6

perl6 Is using junctions in matching possible?

点点圈 提交于 2019-12-01 05:45:50
Is it possible to use junction to match any of the values in a junction? I want to match any of the values in an array. What is the proper way to do it? lisprog$ perl6 To exit type 'exit' or '^D' > my @a=<a b c> [a b c] > any(@a) any(a, b, c) > my $x=any(@a) any(a, b, c) > my $y = "a 1" a 1 > say $y ~~ m/ $x / False > say $y ~~ m/ "$x" / False > my $x = any(@a).Str any("a", "b", "c") > say $y ~~ m/ $x / False > say $y ~~ m/ || $x / False > say $y ~~ m/ || @a / 「a」 > Thanks !! Junctions are not meant to be interpolated into regexes. They're meant to be used in normal Perl 6 expressions,

Terminal ANSI colors does not work with Inline::Perl5 (Data::Printer)

时间秒杀一切 提交于 2019-12-01 03:41:00
问题 The following Perl 5 script: use strict; use warnings; use Data::Printer; my @a = (1,2,3,4); p @a; gives output: (note the blue color), whereas this Perl 6 scripts: use Data::Printer:from<Perl5>; my @a = 1,2,3,4; p @a; gives output: [ [0] 1, [1] 2, [2] 3, [3] 4 ] but the numbers are not colored (as for the Perl 5 case above). System information : $ perl --version This is perl 5, version 29, subversion 3 (v5.29.3) built for x86_64-linux $ perl6 -e '.say for $*DISTRO, $*VM, $*PERL.compiler

What's the difference these two function calling conventions?

淺唱寂寞╮ 提交于 2019-12-01 03:15:50
Functions can be called in a couple ways: say(1, 2, 3) # 123 say: 1, 2, 3 # (1, 2, 3) The latter seems to pass a Positional , but apart from that I don't know how else they differ. Are there any differences that are important to know? What types of situations would you use one over the other? jjmerelo As Raiph tells you above, say: is a label. So you didn't say anything (even though you thought you did) and -- outside use of the REPL -- the compiler will complain that your use of <a b c> was useless: say: <a b c>; # OUTPUT: «WARNINGS for <tmp>:␤Useless use of constant value a b c in sink

perl6 Is using junctions in matching possible?

大兔子大兔子 提交于 2019-12-01 02:25:48
问题 Is it possible to use junction to match any of the values in a junction? I want to match any of the values in an array. What is the proper way to do it? lisprog$ perl6 To exit type 'exit' or '^D' > my @a=<a b c> [a b c] > any(@a) any(a, b, c) > my $x=any(@a) any(a, b, c) > my $y = "a 1" a 1 > say $y ~~ m/ $x / False > say $y ~~ m/ "$x" / False > my $x = any(@a).Str any("a", "b", "c") > say $y ~~ m/ $x / False > say $y ~~ m/ || $x / False > say $y ~~ m/ || @a / 「a」 > Thanks !! 回答1: Junctions

What's the difference these two function calling conventions?

感情迁移 提交于 2019-12-01 00:14:09
问题 Functions can be called in a couple ways: say(1, 2, 3) # 123 say: 1, 2, 3 # (1, 2, 3) The latter seems to pass a Positional , but apart from that I don't know how else they differ. Are there any differences that are important to know? What types of situations would you use one over the other? 回答1: As Raiph tells you above, say: is a label. So you didn't say anything (even though you thought you did) and -- outside use of the REPL -- the compiler will complain that your use of <a b c> was

Why does constraining a Perl 6 named parameter to a definite value make it a required value?

我们两清 提交于 2019-11-30 23:43:53
问题 Consider these subroutines that all take a single named parameter. Named parameters should be optional and I haven't seen anything to say there are exceptions to that. With no type constraints there's no problem; the named parameter is not required. With a type constraint that can accept a type object (no annotation, :U , and :_ ) there is no problem. Parameter '$quux' of routine 'quux' must be an object instance of type 'Int', not a type object of type 'Int'. Did you forget a '.new'? in sub

Parsing a possibly nested braced item using a grammar

白昼怎懂夜的黑 提交于 2019-11-30 21:57:08
I am starting to write BibTeX parser. The first thing I would like to do is to parse a braced item. A braced item could be an author field or a title for example. There might be nested braces within the field. The following code does not handle nested braces: use v6; my $str = q:to/END/; author={Belayneh, M. and Geiger, S. and Matth{\"{a}}i, S.K.}, END $str .= chomp; grammar ExtractBraced { rule TOP { 'author=' <braced-item> .* } rule braced-item { '{' <-[}]>* '}' } } ExtractBraced.parse( $str ).say; Output : 「author={Belayneh, M. and Geiger, S. and Matth{\"{a}}i, S.K.},」 braced-item => 「

Perl6 : What is the best way for dealing with very big files?

随声附和 提交于 2019-11-30 11:26:21
Last week I decided to give a try to Perl6 and started to reimplement one of my program. I have to say, Perl6 is so the easy for object programming, an aspect very painfull to me in Perl5. My program have to read and store big files, such as whole genomes (up to 3 Gb and more, See example 1 below) or tabulate data. The first version of the code was made in the Perl5 way by iterating line by line ("genome.fa".IO.lines). It was very slow and unsable for a correct execution time. my class fasta { has Str $.file is required; has %!seq; submethod TWEAK() { my $id; my $s; for $!file.IO.lines ->

Extracting from .bib file with Perl 6

六眼飞鱼酱① 提交于 2019-11-30 04:52:45
I have this .bib file for reference management while writing my thesis in LaTeX: @article{garg2017patch, title={Patch testing in patients with suspected cosmetic dermatitis: A retrospective study}, author={Garg, Taru and Agarwal, Soumya and Chander, Ram and Singh, Aashim and Yadav, Pravesh}, journal={Journal of Cosmetic Dermatology}, year={2017}, publisher={Wiley Online Library} } @article{hauso2008neuroendocrine, title={Neuroendocrine tumor epidemiology}, author={Hauso, Oyvind and Gustafsson, Bjorn I and Kidd, Mark and Waldum, Helge L and Drozdov, Ignat and Chan, Anthony KC and Modlin, Irvin

Perl6 : What is the best way for dealing with very big files?

时光毁灭记忆、已成空白 提交于 2019-11-29 17:05:18
问题 Last week I decided to give a try to Perl6 and started to reimplement one of my program. I have to say, Perl6 is so the easy for object programming, an aspect very painfull to me in Perl5. My program have to read and store big files, such as whole genomes (up to 3 Gb and more, See example 1 below) or tabulate data. The first version of the code was made in the Perl5 way by iterating line by line ("genome.fa".IO.lines). It was very slow and unsable for a correct execution time. my class fasta