Skip to content

Instantly share code, notes, and snippets.

View VienosNotes's full-sized avatar

D.Aoki VienosNotes

View GitHub Profile
@VienosNotes
VienosNotes / cind.pl
Created February 26, 2012 09:27
なにかの画像を収集するスクリプト
use v6;
my @type = (1..3).list;
my @rare = (0..5).list;
my @num = (1..29).list;
my @plus = (1..3).list;
my $cmd;
for @type X @rare X @num X @plus -> $t, $r, $n, $p {
$cmd = 'wget http://example.com/directory/' ~ $t ~ $r ~ $n.fmt("%03d") ~ $p.fmt("%02d") ~ ".jpg";
#include<stdio.h>
#include<math.h>
int main (int argc, char** argv) {
char* count = argv[1];
int d = 0;
int ans = 0;
while (*(count++) != '\0');
count -= 2;
do {
@VienosNotes
VienosNotes / mapBetween.pl
Created January 5, 2012 09:01
mapBetween
use v6;
sub mapBetween ($op, *@list) {
(@list Z @list[1..*]).map({ $op($^a,$^b) });
}
my @list = 1,2,3,4,5;
say mapBetween(&infix:<+>, @list);
say mapBetween(&infix:<+>, 1,2,3,4,5);
# 3 5 7 9
@VienosNotes
VienosNotes / lisp.pl
Created December 26, 2011 17:06
Lisp subset implementation in Perl6 Grammar and Action
# This version is very old!
# Latest code is here ↓
# https://github.com/VienosNotes/Domino/blob/master/domino.pl
use v6;
grammar Lisp {
token left { '(' };
token right { ')' };
token num { \d+ }
@VienosNotes
VienosNotes / CA.pl
Created December 15, 2011 06:25
1-Dimentional Cellular Automaton
use v6;
class CA {
has @.data;
has @.rule;
method new ($rule, $length, $population) {
my @data = (1 xx $population, 0 xx $length - $population).pick(*);
my @rule = $rule.fmt("%08b").flip.comb.map({.Int});
self.bless(*, data => @data, rule => @rule);
use v6;
class T {
has $.with_accessor;
has $!without_accessor;
method new ($i as Int) {
self.bless(*, with_accessor => $i, without_accessor => $i);
}
@VienosNotes
VienosNotes / split.pl
Created November 16, 2011 05:21
Image spliter
use strict;
use warnings;
use Imager;
mkdir "numbers";
mkdir "modified";
mkdir "concat";
for (@ARGV) {
chop for 1..4;
@VienosNotes
VienosNotes / Mandelbrot.pl
Created November 9, 2011 19:10
Mandelbrot with Perl6
use v6;
class Bitmap {
has IO $!file;
has %!header;
has $!w_count;
has $!h_count;
has $!remainder;
has $!template;
@VienosNotes
VienosNotes / dice2.pl
Created August 24, 2011 17:45
mD6 + nD10 in Perl6 (2)
use v6;
multi sub infix:<D> ($lhs, $rhs) {
my $sum = 0;
$sum += $rhs.rand.Int for 1..$lhs;
return $sum;
}
multi sub infix:<D> ($lhs, $rhs where {$_ == 6} ) {
return &infix:<D>.candidates[0]($lhs, $rhs) + $lhs;
@VienosNotes
VienosNotes / dice1.pl
Created August 24, 2011 17:00
mD6 + nD10 in Perl6 (1)
use v6;
sub mD6 {
gather { take 6.rand.Int + 1 for 0..* }
}
sub nD10 {
gather { take 10.rand.Int for 0..* }
}