Skip to content

Instantly share code, notes, and snippets.

Created June 29, 2015 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/c6d54c302f4c4a63c21b to your computer and use it in GitHub Desktop.
Save anonymous/c6d54c302f4c4a63c21b to your computer and use it in GitHub Desktop.
xkcd 1537
module Xkcd::Types {
multi sub infix:<+>(Int $n, Str $m) { ($n + $m.Int).Str }
multi sub infix:<+>(Str $n, @a where !@a) { "[$n]" }
multi sub infix:</>(Int $n, 0) is export { NaN }
multi sub infix:<+>(NaN, Int $n) { class NaP {}; }
multi sub infix:<+>("", "") { '"+"' }
multi sub infix:<+>(Array $a, Int $n) is export { so none(|$a) == $n }
};
import Xkcd::Types;
.perl.say for ( 2 + "2", "2" + [], (2/0), (2/0) + 2, ""+"", [1,2,3] + 2, [1,2,3] + 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment