raku

Extracting from .bib file with Perl 6

一世执手 提交于 2019-11-29 02:23:02
问题 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

How do I “flatten” a list of lists in perl 6?

断了今生、忘了曾经 提交于 2019-11-29 01:47:42
Let's say I want all permutations of 2 letters out of a, b and c. I can do: my @perm = <a b c>.combinations(2)».permutations; say @perm; # [((a b) (b a)) ((a c) (c a)) ((b c) (c b))] which is close, but not exactly what I need. How do I “flatten” this so that I get: # [(a b) (b a) (a c) (c a) (b c) (c b)] ? raiph See also "a better way to accomplish what I (OP) wanted" . See also "Some possible solutions" answer to "How can I completely flatten a Perl 6 list (of lists (of lists) … )" question . Add a subscript my \perm = <a b c>.combinations(2)».permutations; say perm; # (((a b) (b a)) ((a c)

I can create filehandles to strings in Perl 5, how do I do it in Perl 6?

孤者浪人 提交于 2019-11-27 23:32:54
问题 In Perl 5, I can create a filehandle to a string and read or write from the string as if it were a file. This is great for working with tests or templates. For example: use v5.10; use strict; use warnings; my $text = "A\nB\nC\n"; open(my $fh, '<', \$text); while(my $line = readline($fh)){ print $line; } How can I do that in Perl 6? The following doesn't work for Perl 6 (at least not for my instance of Perl6 running on MoarVM 2015.01 from the January 2015 release of Rakudo Star on 64-bit

Is that a Perl 6 Hash or Block?

给你一囗甜甜゛ 提交于 2019-11-27 17:47:51
问题 This is a bit of unexpected behavior that's likely to bite beginners. First, is this intended? Second, what other things does Perl 6 use to guess which object to create? Does it start off thinking it's Block or Hash and change later, or does it decide on the end? You can construct a Hash with braces and the fat arrow: my $color-name-to-rgb = { 'red' => 'FF0000', }; put $color-name-to-rgb.^name; # Hash Using the other Pair notation creates a Hash too. my $color-name-to-rgb = { :red('FF0000'),

How can error reporting in grammars be improved?

烂漫一生 提交于 2019-11-27 09:15:30
Is there a way to get Perl 6 to generate an error message if a grammar does not match? Or at least return the position of the last data it processed? It is quite hard to fix syntax errors if all I get from the parser is 'no match'. If your focus is generating messages for users of your grammar, see Generating Good Parse Errors from a Parser and Grammar::ErrorReporting . The rest of this answer is about debugging. First, you can embed arbitrary closures (code) in Perl 6 rules (or tokens or regexes). Just type { your code goes here } in the middle of a rule. So you could just sprinkle { say ...

How can error reporting in grammars be improved?

会有一股神秘感。 提交于 2019-11-26 14:36:15
问题 Is there a way to get Perl 6 to generate an error message if a grammar does not match? Or at least return the position of the last data it processed? It is quite hard to fix syntax errors if all I get from the parser is 'no match'. 回答1: If your focus is generating messages for users of your grammar, see Generating Good Parse Errors from a Parser and Grammar::ErrorReporting. The rest of this answer is about debugging. First, you can embed arbitrary closures (code) in Perl 6 rules (or tokens or