Perl6-Pugs

 view release on metacpan or  search on metacpan

ext/Math-Basic/lib/Math/Basic.pm  view on Meta::CPAN

use v6-alpha;
module Math::Basic;

sub pi() is export(:constants) {3.141592653589793}

misc/Date/lib/Time/Zone.pm  view on Meta::CPAN


class Time::Zone;

has Str $.tz;

sub tz(Str $tz) returns Time::Zone is export {
    Time::Zone.new(:tz($tz));
}

misc/pX/Common/lrep/iterator_engine.p6t  view on Meta::CPAN

# pX/Common/p6rule.t - fglock

use v6-alpha;
#use strict;
#use warnings;

require 'iterator_engine.pl';

#use Test;  -- errors?
sub ok($val,$comment) { 
  print "not " unless $val;
  print "ok - $comment\n";
}

#use Data::Dumper;
#$Data::Dumper::Indent = 1;
#$Data::Dumper::Pad = '# ';

ok( 1, "compiled" );

misc/pX/Common/redsix/redsix_snapshot.rb  view on Meta::CPAN

sub push($o,*@a){$o.push(*@a)}
sub unshift($o,*@a){$o.unshift(*@a)}
sub eval($code){rUBYeval6q($code)}
sub sprintf($f,*@a){rUBYsprintf($f,*@a)}
sub hash(*@a){ my %h = *@a; %h }
sub elems($a){ $a.elems }
sub end($a){ $a.end }
sub undefine($x){$x = undef}
sub undef(){rUBYpundef}
sub lcfirst($s=$+_){$s.lcfirst}
sub lc($s=$+_){$s.lc}
sub ucfirst($s=$+_){$s.ucfirst}
sub uc($s=$+_){$s.uc}
sub capitalize($s=$+_){$s.capitalize}
sub bytes($s=$+_){$s.bytes}
sub chars($s=$+_){$s.chars}
sub index($s=$+_,$ss,$from=0){$s.index($ss,$from)}
sub rindex($s=$+_,$ss,$from=0){$s.rindex($ss,$from)}
#sub chomp($a){ $a.chomp }
sub chomp($s=$+_){$s.chomp}
sub trans($s,*@m){$s.trans(*@m)}
sub keys($o){$o.keys}
sub values($o){$o.values}
sub kv($o){$o.kv}
sub sort($o){$o.sort}
sub pi(){raw_rUBY('Math::PI')}
sub sin($n){raw_rUBY('Math.sin(nS.as_n)')}
sub cos($n){raw_rUBY('Math.cos(nS.as_n)')}
sub tan($n){raw_rUBY('Math.tan(nS.as_n)')}
sub asin($n){raw_rUBY('Math.asin(nS.as_n)')}
sub acos($n){raw_rUBY('Math.acos(nS.as_n)')}
sub atan($n,$n2=undef){
  $n2 ?? raw_rUBY('Math.atan2(nS.as_n,n2S.as_n)') !! raw_rUBY('Math.atan(nS.as_n)') }
our $*OS = raw_rUBY('Config::CONFIG["host_os"]');
our $*OSVER = undef;
our $*PERVER = "5.13.0";

misc/pX/audreyt/p6ast.hs  view on Meta::CPAN

    = VConstant  Unboxed     -- 1
    | VObject    Object      -- Foo.new(...)
    | VForeign   Foreign     -- perl5:DBI.connect()
    | VCode      Code        -- {...}
    | VType      Type        -- ::CGI
    | VCapture   Capture     -- \(...)
    | VSignature Signature   -- :(...)

package Main;

sub f (constant $x = 1) { ... }

f(); # $x retains last value

submethod BUILD (has $x) { ... }
submethod BUILD ($.x) { ... }
$Main::x


positional named named_slurpy

method f (Moose $self where {...}: ...)


(@a [$x, $y, *@rest [*, *, *, $z]]  ) := [1,2,3]


sub f (:v($verbose), :$verbose, :$v) {
    say $verbose;
}

f(v=>1);
f(verbose=>1);



Any $self (\)

sub f ($x, $x, $x) { }

method f ($x, $y) {}

data Param = MkParam
    { paramVariable     :: Identifier
    , paramTypes        :: [Type]       -- Static pieces of inferencer-food
    , paramConstraints  :: [Code]       -- Dynamic pieces of runtime-mood
    , paramUnpacking    :: Maybe Signature
    , paramDefault      :: Maybe Expression
    , paramLabel        :: Identifier

perl5/Pugs-Compiler-Perl6/t/05-sub.t  view on Meta::CPAN


# Checking that testing is sane: subroutines

use v6-alpha;

say '1..5';

sub ok($num) {
    say "ok $num";
}

ok(1);
ok 2;

my $counter = 2;
sub ok_auto {
    ++$counter;
    say "ok $counter";

perl5/Pugs-Compiler-Rule/t6/iterator_engine.pl  view on Meta::CPAN

# pX/Common/p6rule.t - fglock

use v6-alpha;
use Pugs::Runtime::Rule;
#use strict;
#use warnings;

#require 'iterator_engine.pl';

#use Test;  -- errors?
sub ok($val,$comment) { 
  print "not " unless $val;
  print "ok - $comment\n";
}

#use Data::Dumper;
#$Data::Dumper::Indent = 1;
#$Data::Dumper::Pad = '# ';

ok( 1, "compiled" );

src/perl6/Prelude.pm  view on Meta::CPAN

    }
    our &ceil ::= &ceiling;

    sub floor($n) is primitive is safe {
        Num::round_gen($n, &Num::do_floor)
    }
}

# *pi is non-spec (S29);  Should require use Math::Basic :constants;
# use Math::Basic :GLOBAL<pi>; fails to define *pi, so...
sub pi() is primitive is builtin is safe {Math::Basic::pi}


sub sprintf ($fmt, *@args) is primitive is builtin is safe {
    my $flen = $fmt.chars;
    my $fi = 0;
    my $ai = 0;
    my $str = "";
    while ($fi < $flen) {
        # optional non-conversion text
        my $idx = index($fmt,"%",$fi);

t/01-sanity/05-sub.t  view on Meta::CPAN

use v6-alpha;

# Checking that testing is sane: subroutines


say '1..4';

sub ok($num) {
    say "ok $num";
}

ok(1);
ok 2;

my $counter = 2;
sub ok_auto {
    ++$counter;
    say "ok $counter";

t/junction/misc_junctions.t  view on Meta::CPAN

Tests junction examples from Synopsis 03 

j() is used to convert a junction to canonical string form, currently
just using .perl until a better approach presents itself.

L<S03/"Junctive operators">

=cut

# Canonical stringification of a junction
sub j (Junction $j) { return $j.perl }

{
    # L<S03/"Junctive operators" /They thread through operations/>
    my ($got, $want);
    $got = ((1|2|3)+4);
    $want = (5|6|7);
    is( j($got), j($want), 'thread + returning junctive result');

    $got = ((1|2) + (3&4));
    $want = ((4|5) & (5|6));



( run in 4.689 seconds using v1.01-cache-2.11-cpan-a5162978ef8 )