読者です 読者をやめる 読者になる 読者になる

at kaneshin

Free space for me.

実はSyntax Highlightできるらしい

JavaScript, Perl, CSSのソースはハイライトされるの!?

var foo = {
  bar: 10,
  baz: function(num, callback) {
    callback(num * num);
  },
  qux: function(num, callback) {
    var self = this;
    this.baz(num, function(res) { 
      callback(res + self.bar);
    });
  }
};
foo.qux(5, function(res) {
  console.log(res);
});
package Collatz;
use strict;
use warnings;
use utf8;
our $VERSION = '0.10';

use constant INVALID_NUM => -1;

sub do_collatz {
    my $num = shift;
    my @ret = ();
    if ( _valid_arg( $num ) > 0 ) {
        push @ret, $num;
    }
    else {
        return INVALID_NUM;
    }
    until ( $num == 1) {
        $num = $num % 2 ? 3 * $num + 1 : $num / 2;
        push @ret, $num;
    }
    return @ret;
}

sub _valid_arg {
    my $arg = shift;
    return ( $arg =~ /^\d+$/ ? $arg : INVALID_NUM );
}
body {
  width: 800px;
  margin: 0 auto;
  padding: 0;
}