Skip to content

Instantly share code, notes, and snippets.

@tomcha
tomcha / sref.pl
Created Aug 11, 2020
scalar reference
View sref.pl
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
my $a = 1;
my $b = $a;
$b *= 10;
View gist:363a26e903db7697b6e40ccb4154ae86
#!/usr/bin/env ruby
(y, x) = gets.chomp.split(/ /).map(&:to_i)
now = [1, 1]
addy = 1
addx = 1
puts "#{now[0]}, #{now[1]}"
while
now[0] += addy
now[1] += addx
View gist:5b6fbee7cb92a851081930c85e46cf17
#!/usr/bin/env ruby
(y, x) = gets.chomp.split(/ /).map(&:to_i)
now = [1, 1]
addy = 1
addx = 1
puts "#{now[0]}, #{now[1]}"
while
now[0] += addy
now[1] += addx
View lifegame.go
package main
import (
"fmt"
"math/rand"
"time"
)
const (
clear = "\033[2J"
@tomcha
tomcha / fatcomma.pl
Last active Oct 20, 2019
fatcomma.pl
View fatcomma.pl
#!/usr/bin/env perl
use strict;
use warnings;
my ($a, $b, $c) = (1, 2, 3);
my ($aa, $bb, $cc) = (1 => 2 => 3);
print "$b\n";
print "$cc\n";
View ref_allow.pl
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use DDP { deparse => 1 };
my $allow = {1 => ['a', 'b', 'c'], 2 => ['d', 'e', 'f']};
@tomcha
tomcha / fizzbuzz.go
Created Apr 24, 2019
fizz buzz + goroutine
View fizzbuzz.go
package main
import (
"fmt"
"sync"
)
func main() {
var wg sync.WaitGroup
wg.Add(1)
@tomcha
tomcha / guess-ad-year.pl
Created Apr 14, 2019
Perl入学式 第1回 ピザ会 課題 2019/04/13 回答
View guess-ad-year.pl
#!/usr/bin/env perl
# guess-ad-year.pl - 和暦を引数に与えると西暦年を応えてくれる
# ad は A.D. (Anno Domini = 西暦年) の略
#
# 例:
# guess-ad-year.pl 平成30年
# 2018年
# guess-ad-year.pl 昭和54年
# 1979年
@tomcha
tomcha / dijkstra.pl
Created Apr 13, 2019
ダイクストラ法
View dijkstra.pl
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use DDP { deparse => 1 };
my $graph = [];
for my $line (<DATA>){
View Trapezoidal.pl
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use DDP { deparse => 1 };
print "a b(区間)を入力してください(スペース区切り) >";
chomp(my $input = <STDIN>);