Skip to content

Instantly share code, notes, and snippets.

@Mouq
Mouq / gist:8950902
Last active August 29, 2015 13:56 — forked from anonymous/gist:8928045
say("+123.456e10" ~~ /
:my token SIGN { <[+-]> }
:my token MANTISSA { \d+ '.'? \d* | '.' \d+ }
:my token EXPONENT { <[eE]> <SIGN>? \d+ }
<SIGN>? <MANTISSA> <EXPONENT>?
/)
# ∂
class RT61918 {
has $.inst is rw;
has $!priv is rw;
has $.string = 'krach';
method init {
$.inst = [ rand, rand ];
$!priv = [ rand, rand ].perl;
}
}
use v6;
# Partial solution to https://codegolf.stackexchange.com/questions/20957
enum 数 <零 一 二 三 四 五 六 七 八 九 十>;
sub infix:<加> (\第一, \第二) { 第一 + 第二 }
sub infix:<减> (\第一, \第二) { 第一 - 第二 }
sub infix:<乘以> (\第一, \第二) { 第一 * 第二 }
sub infix:<除以> (\第一, \第二) { 第一 / 第二 }
sub infix:<等于> (\第一, \第二) { 第一 == 第二 }
@Mouq
Mouq / doc.diff
Last active August 29, 2015 13:56
diff --git a/type-graph.txt b/type-graph.txt
index 0c56466..077dd24 100644
--- a/type-graph.txt
+++ b/type-graph.txt
@@ -152,11 +152,6 @@ role TypedArray[::TValue] does Positional[TValue]
# Collections: Associative
role Associative[::T = Mu]
-role Baggy
-class Bag is Iterable does Associative does Baggy
=begin pod
=TITLE Things Rakudo Should Be Able to Do or Ought to Have
My personal TODO list, things that other people haven't already picked up to work on
=begin item
Ecosystem stuff
=item Slang::Indent
diff --git a/lib/Pod/To/HTML.pm b/lib/Pod/To/HTML.pm
index 797ea2d..9564d77 100644
--- a/lib/Pod/To/HTML.pm
+++ b/lib/Pod/To/HTML.pm
@@ -248,7 +248,7 @@ multi sub node2html(Pod::Block::Named $node) returns Str {
return qq{<div class="nested">\n} ~ node2html($node.content) ~ qq{\n</div>\n};
}
when 'output' { return "<pre>\n" ~ node2inline($node.content) ~ "</pre>\n"; }
- when 'pod' { return node2html($node.content); }
+ when 'pod' { return qq[<span class="{$node.config<class>}">\n{node2html($node.content)}</span>\n] }
@Mouq
Mouq / 01-arithmetic.p6
Last active August 29, 2015 13:57
Potential Grammar::Precedence test
use Test;
use Grammar::Precedence;
grammar Arithmetic does Grammar::Precedence {
token TOP { <EXPR> }
# self.push-prec($str) makes $str a new
# precedence level and the loosest level.
# self.unshift-prec($str) would therefor
# make $str a new precedence level and
@Mouq
Mouq / gif-grammar.p6
Last active August 29, 2015 13:57
Binary decoding
# What about encoding back?
# grammar Image::GIF::Grammar {
class Image::GIF::Decoder is Decoder {
token TOP {
:my $*CT-valid; # set in lexical <packed>
:my $*CT-size; # also set in <packed>
<header>
<screen>
<color-table>?
<labeled>*
S02-bits.pod
1263-The final element of an array is subscripted as C<@a[*-1]>,
1264-which means that when the subscripting operation discovers a C<Code:($)>
1265-object for a subscript, it calls it and supplies an argument indicating
1266-the number of elements in (that dimension of) the array. See S09.
1267-
1268:=head3 The C<HyperWhatever> Type
1269-
1270:A variant of C<*> is the C<**> term, which is of type C<HyperWhatever>.
1271-It is generally understood to be a multidimension form of C<*> when
my ($f,&t,&r,&c)=lines.comb(/<-[{}]>+/).SetHash,&substr,&return,&chars;while $f>1
{@$f.sort(-*.&c).combinations(2).map({sub
(\a,\b){r \(a,b,:m(a):v(c b))if a.index(b);for b.&c...1
->\v{->\x,\y{r \(a,b,:m(x~t y,v):v(v))if t(x,*-v)eq t y,0,v}(|$_)for
[a,b],[b,a]}}(|$_)}).sort(-*.<v>).uniq(:as{any @$_}:with(&[eq])).map:{$f{@$_}»--;$f{.<m>}++}}
say @$f