Skip to content

Instantly share code, notes, and snippets.

View tyru's full-sized avatar
🏠
Working from home

Fujiwara Takuya tyru

🏠
Working from home
View GitHub Profile
" http://d.hatena.ne.jp/thinca/20130708/1373210009
noremap <silent> <buffer> <expr> j <SID>jk(v:count1)
noremap <silent> <buffer> <expr> k <SID>jk(-v:count1)
noremap <silent> <buffer> <expr>
\ gg (v:count > 0 ? <SID>jk(v:count-line('.')) : <SID>gg(1))
noremap <silent> <buffer> <expr>
\ G (v:count > 0 ? <SID>jk(v:count-line('.')) : <SID>gg(0))
@tyru
tyru / map.pl
Created February 24, 2009 02:11
use strict;
use warnings;
sub my_map (&@) {
my $code = shift;
my @array;
for (@_) {
local $_ = $_;
push @array, $code->();
}
#!/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;
(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)))]))
@tyru
tyru / map.pl
Created February 24, 2009 02:29
use strict;
use warnings;
sub my_map (&@) {
my $code = shift;
my @array;
for (@_) {
local $_ = $_;
push @array, $code->();
}
(use util.stream)
; ストリームの負数番目を取ると死ねる(GCが落ちる)
(define fib
(stream-cons 0
(stream-cons 1
(stream-map + fib (stream-cdr fib)))))
; ------------------------------------------------
(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)))
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
{
local $SIG{__WARN__} = sub {
my $errmsg = shift;
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Perl6::Say;
BEGIN {
say 'one';
}
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Perl6::Say;
sub a2 {
{ package DB; () = caller 1 }