Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Fujiwara Takuya tyru

🏠
Working from home
View GitHub Profile
View map.pl
use strict;
use warnings;
sub my_map (&@) {
my $code = shift;
my @array;
for (@_) {
local $_ = $_;
push @array, $code->();
}
View map.pl
use strict;
use warnings;
sub my_map (&@) {
my $code = shift;
my @array;
for (@_) {
local $_ = $_;
push @array, $code->();
}
View closure.pl
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Encode qw( encode );
use FileHandle;
use Getopt::Long;
use Perl6::Say;
use Pod::Usage;
View continuation6.scm
(use util.stream)
; ストリームの負数番目を取ると死ねる(GCが落ちる)
(define fib
(stream-cons 0
(stream-cons 1
(stream-map + fib (stream-cdr fib)))))
; ------------------------------------------------
View flat-list.scm
(use srfi-1)
; flat-list tree
(define (flat-list tree)
(cond
[(null? tree) '()]
[(list? (car tree))
(append (flat-list (car tree)) (flat-list (cdr tree)))]
[else (cons (car tree) (flat-list (cdr tree)))]))
View keyword-procs2.scm
(use srfi-1)
(use gauche.test)
;; return values of pair keywords and single keywords.
(define (pairs&singles lis)
(define (loop lis pairs singles)
(if (null? (cdr lis))
(if (and (pair? lis) (keyword? (car lis)))
(values (filter (lambda (elt) (not (eq? (car lis) elt)))
View signal-handler.pl
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
{
local $SIG{__WARN__} = sub {
my $errmsg = shift;
View begin-block.pl
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Perl6::Say;
BEGIN {
say 'one';
}
View db_args.pl
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Perl6::Say;
sub a2 {
{ package DB; () = caller 1 }
View launch_at_boot.pl
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use constant {
MAX_TERM_WIDTH => 42
};
use Win32::Die;
use Win32::Process;