This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From f3c3e42801cc58889a7994d043891d04d16f5ba2 Mon Sep 17 00:00:00 2001 | |
| From: Lucien Grondin <[email protected]> | |
| Date: Tue, 30 Jul 2013 14:55:22 +0200 | |
| Subject: [PATCH] first attempt of ethiopian exponentiation | |
| --- | |
| src/core/Complex.pm | 6 ++++++ | |
| 1 file changed, 6 insertions(+) | |
| diff --git a/src/core/Complex.pm b/src/core/Complex.pm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 7993316217fc1e137a757ab710077e68cb7bb350 Mon Sep 17 00:00:00 2001 | |
| From: Lucien Grondin <[email protected]> | |
| Date: Tue, 30 Jul 2013 15:23:07 +0200 | |
| Subject: [PATCH 2/2] second attempt of ethiopian exponentiation | |
| --- | |
| src/core/Complex.pm | 8 +++++--- | |
| 1 file changed, 5 insertions(+), 3 deletions(-) | |
| diff --git a/src/core/Complex.pm b/src/core/Complex.pm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 94aca2cbcba52f51708ae37904234096ec8781c2 Mon Sep 17 00:00:00 2001 | |
| From: Lucien Grondin <[email protected]> | |
| Date: Tue, 30 Jul 2013 15:38:18 +0200 | |
| Subject: [PATCH] first commit | |
| --- | |
| src/core/Complex.pm | 7 +++++++ | |
| 1 file changed, 7 insertions(+) | |
| diff --git a/src/core/Complex.pm b/src/core/Complex.pm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From cca7ffe335a65cbf1c7c0e95a45017e16e5979fa Mon Sep 17 00:00:00 2001 | |
| From: Lucien Grondin <[email protected]> | |
| Date: Tue, 30 Jul 2013 15:59:12 +0200 | |
| Subject: [PATCH 2/2] fixing typo in signature | |
| --- | |
| src/core/Complex.pm | 2 +- | |
| 1 file changed, 1 insertion(+), 1 deletion(-) | |
| diff --git a/src/core/Complex.pm b/src/core/Complex.pm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sub ethiop(Complex:D \z, Int:D \n where n > 0) { | |
| my ($p, $z, $n) = 1, z, n; | |
| until $n == 0 { | |
| $p *= $z unless $n %% 2; | |
| $n div= 2; | |
| $z *= $z; | |
| } | |
| return $p; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sub ethiopicmult($a, $b) { | |
| my @left = $a, * div 2 ... 1; | |
| my @right := $b, 2 * * ... *; | |
| [+] map *.value, grep *.key % 2, (@left Z=> @right) | |
| } | |
| say ethiopicmult 17, 34; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sub longest_increasing_subsequence(@d) { | |
| my @l = [[].item]; | |
| for ^@d -> $i { | |
| @l.push: [ max(:by(*.elems), grep { .[*-1] < @d[$i] }, @l[0..$i]).list, @d[$i] ].item; | |
| } | |
| return max :by(*.elems), @l; | |
| } | |
| say .perl given longest_increasing_subsequence <0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15>».Int; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| role BinaryTree[::T] { | |
| has T $!value; | |
| has BinaryTree[T] ($.left, $.right); | |
| method replace-all(T $value) { | |
| $!value = $value; | |
| $.left.?replace-all($value); | |
| $.right.?replace-all($value); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| grammar Lambda { | |
| =for description | |
| I was trying to write a grammar for Lambda-calculus, | |
| and I failed parsing a simple 'λx.x x' string. | |
| rule TOP { ^ <expression> $ } | |
| rule expression { | |
| | \( ~ \) <expression> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Suffix {...} | |
| class Edge {...} | |
| class Node { has Int $.suffix_node is rw = -1 } | |
| subset Explicit of Suffix where { .first_char_index > .last_char_index } | |
| subset Implicit of Suffix where { .last_char_index >= .first_char_index } | |
| my @Nodes = Node.new; | |
| my Blob $T; | |
| class Suffix { |