| 1 | package Dallycot::Library::Core; | ||
| 2 | 9 | our $AUTHORITY = 'cpan:JSMITH'; | |
| 3 | |||
| 4 | # ABSTRACT: Core library of useful functions | ||
| 5 | |||
| 6 | 9 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 9 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 9 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 9 | ▶ | use Dallycot::Library; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | 9 | ns 'http://www.dallycot.net/ns/core/1.0#'; | |
| 14 | |||
| 15 | 9 | uses 'http://www.dallycot.net/ns/loc/1.0#'; | |
| 16 | |||
| 17 | 9 | define nest => <<'EOD'; | |
| 18 | y-combinator( | ||
| 19 | (self, function, count) :> ( | ||
| 20 | (count > 3) : function . function . function . self(self, function, count-3) | ||
| 21 | (count = 3) : function . function . function | ||
| 22 | (count = 2) : function . function | ||
| 23 | (count = 1) : function | ||
| 24 | ( ) : { () }/1 | ||
| 25 | ) | ||
| 26 | ) | ||
| 27 | EOD | ||
| 28 | |||
| 29 | 9 | define 'list-cons' => <<'EOD'; | |
| 30 | y-combinator( | ||
| 31 | (self, first, second) :> ( | ||
| 32 | (?first) : [ first', self(self, first..., second)] | ||
| 33 | ( ) : second | ||
| 34 | ) | ||
| 35 | ) | ||
| 36 | EOD | ||
| 37 | |||
| 38 | define | ||
| 39 | length => ( | ||
| 40 | hold => 0, | ||
| 41 | arity => 1, | ||
| 42 | options => {}, | ||
| 43 | ), | ||
| 44 | sub { | ||
| 45 | 3 | ▶ | my ( $engine, $options, $thing ) = @_; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 46 | |||
| 47 | 3 | $thing->calculate_length($engine); | |
| 48 | 9 | }; | |
| 49 | |||
| 50 | 9 | 1; | |