Skip to content

Instantly share code, notes, and snippets.

View felher's full-sized avatar

felher felher

  • Olyro GmbH
View GitHub Profile
@felher
felher / tic-tac-toe.pl
Created November 24, 2011 16:49
tic-tac-toe in perl6 for Rosetta Code
use v6;
my @board = 1..9;
my @winning-positions = [0..2], [3..5], [6..8], [0,3,6], [1,4,7], [2,5,8],
[0,4,8], [6,4,2];
sub get-winner() {
for @winning-positions {
return (@board[$_][0], $_) if [eq] @board[$_];
}
use v6;
# the modexp-function from: http://rosettacode.org/wiki/Modular_exponentiation
sub modexp(Int $a is copy, Int $b is copy, $n) {
my $c = 1;
repeat while $b div= 2 {
($c *= $a) %= $n if $b % 2;
($a *= $a) %= $n;
}
$c;
@felher
felher / gist:2378269
Created April 13, 2012 16:45
make spectest after make exception return True on .Bool again
0 0 felher@win6074d [ ~/sources/perl6/rakudo_nom ] %> make spectest -j 10
cd t/spec && git pull
remote: Counting objects: 539, done.
remote: Compressing objects: 100% (186/186), done.
remote: Total 402 (delta 296), reused 305 (delta 201)
Receiving objects: 100% (402/402), 47.99 KiB, done.
Resolving deltas: 100% (296/296), completed with 122 local objects.
From git://github.com/perl6/roast
4cfafd6..23a618d master -> origin/master
First, rewinding head to replay your work on top of it...
@felher
felher / nom patch
Created April 14, 2012 13:36
Exceptoin.Bool patches
From 68286f0c9998650eb33dbc5047ccfd294a0f0c9f Mon Sep 17 00:00:00 2001
From: Felix Herrmann <felix@herrmann-koenigsberg.de>
Date: Fri, 13 Apr 2012 20:38:52 +0200
Subject: [PATCH] Make Exception.Bool return True
---
src/core/Exception.pm | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/src/core/Exception.pm b/src/core/Exception.pm
From 394831b72d0004c1e2029bc143afa362a3d2a538 Mon Sep 17 00:00:00 2001
From: Felix Herrmann <felix@herrmann-koenigsberg.de>
Date: Sun, 15 Apr 2012 22:39:44 +0200
Subject: [PATCH] add a few typed IO exceptions
---
src/core/Exception.pm | 56 +++++++++++++++++++++++++++-
src/core/IO.pm | 97 +++++++++++++++++++++++++++++++++++++------------
2 files changed, 128 insertions(+), 25 deletions(-)
@felher
felher / gist:2587005
Created May 3, 2012 16:28
some thinking about exceptions
diff --git a/src/core/Exception.pm b/src/core/Exception.pm
index bab8e99..453613b 100644
--- a/src/core/Exception.pm
+++ b/src/core/Exception.pm
@@ -156,6 +156,9 @@ my role X::OS {
}
my role X::IO does X::OS { };
+my role X::IO::FileNotFound {
+ has $.file-not-found;
@felher
felher / p6doc patch
Created July 6, 2012 10:10
X::Numeric::Real -- finalyy
From c309e19aa95f03939a3ca9b824cc2f7f435cb3bc Mon Sep 17 00:00:00 2001
From: Felix Herrmann <felix@herrmann-koenigsberg.de>
Date: Fri, 6 Jul 2012 13:39:13 +0200
Subject: [PATCH] [Numeric] add coercion to Rat/Num/Int/Real
---
lib/Numeric.pod | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/lib/Numeric.pod b/lib/Numeric.pod
From d5436c373bf030d23111083a992f55f2b57b10cf Mon Sep 17 00:00:00 2001
From: Felix Herrmann <felix@herrmann-koenigsberg.de>
Date: Fri, 27 Jul 2012 13:29:26 +0200
Subject: [PATCH] add Template::Mojo as a dependency of Bailador
---
Makefile | 1 +
skel/tools/build/Makefile.in | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
@felher
felher / Main.patch
Created July 30, 2012 10:12
A patch to let Main.pm output a usage message instead of dieing due to bind failure when passed --help or other unexpected named parameters
From fd9b8428a96d9fbbe8e19d9c89fffda6e7e15dd4 Mon Sep 17 00:00:00 2001
From: Felix Herrmann <felix@herrmann-koenigsberg.de>
Date: Mon, 30 Jul 2012 12:06:00 +0200
Subject: [PATCH] make Main.pm output a usage message on an unexpected named
argument instead of bind failing
---
src/core/Main.pm | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
@felher
felher / Temporal.patch
Created August 2, 2012 21:20
Patch for Date. Otherwise Date.new(year => 2012) fails because $month/$day are of type Any by default and therefore not compatible with their Int-typed instance variables and because they'd be uninitialized
From 6beffa8d2f4b18fcabd0c83a93310bc70a122ea3 Mon Sep 17 00:00:00 2001
From: Felix Herrmann <felix@herrmann-koenigsberg.de>
Date: Thu, 2 Aug 2012 20:07:03 +0200
Subject: [PATCH] [Temporal] change constructor of Date to use default values
for year/month/day
---
src/core/Temporal.pm | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)