Skip to content

Instantly share code, notes, and snippets.

Created October 19, 2015 21:27
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/25143c75e96f5dd54940 to your computer and use it in GitHub Desktop.
Save anonymous/25143c75e96f5dd54940 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl6
constant FACTORS = do {
my %intervals = 'smhdy'.comb Z=> [\*] 1, 60, 60, 24, 365;
my @pfx = 'yzafpnum kMGTPEZY'.comb;
my %scales = @pfx Z=> (
{@_[@pfx.elems div 2] = 1;@_} given
10 X** (
3 X* (
(-@pfx div 2) X+ 1..@pfx
)));
%scales<f>:delete; # No support for femto-
my %factors = (%scales.keys X~ %intervals.keys)>>.trim Z=> (%scales.values X* %intervals.values);
%factors;
}
constant FACTORS2 = do {
my %factors =
s => 1,
m => 60,
h => 3600,
d => 86400,
y => 31536000,
;
for %factors.keys.eager {
%factors{"Y$_"} = 1000000000000000000000000 * %factors{$_};
%factors{"Z$_"} = 1000000000000000000000 * %factors{$_};
%factors{"E$_"} = 1000000000000000000 * %factors{$_};
%factors{"P$_"} = 1000000000000000 * %factors{$_};
%factors{"T$_"} = 1000000000000 * %factors{$_};
%factors{"G$_"} = 1000000000 * %factors{$_};
%factors{"M$_"} = 1000000 * %factors{$_};
%factors{"k$_"} = 1000 * %factors{$_};
%factors{"m$_"} = 0.001 * %factors{$_};
%factors{"u$_"} = 0.000001 * %factors{$_};
%factors{"n$_"} = 0.000000001 * %factors{$_};
%factors{"p$_"} = 0.000000000001 * %factors{$_};
%factors{"a$_"} = 0.000000000000000001 * %factors{$_};
%factors{"z$_"} = 0.000000000000000000001 * %factors{$_};
%factors{"y$_"} = 0.000000000000000000000001 * %factors{$_};
}
%factors;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment