This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
GeneticAlgorithm Class | |
### | |
Gene = require "./Gene" | |
class GA | |
# 個体数, 評価関数 | |
constructor: (@population, @gene_size) -> | |
@genes = (new Gene(null, @gene_size) for x in [0...population]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// test1 | |
console.log(getLineNumber()); | |
// test2 | |
var test = (function test() { | |
console.log(getLineNumber()); | |
return test; | |
})(); | |
var obj = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ロジスティック写像 | |
# 周期倍加分岐図 | |
require(compiler) | |
# 設定 | |
x0 <- 0.1 | |
aR <- 29000:40000 / 10000 | |
tR <- 1900:2000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function download(url, filename) { | |
var a = document.createElement("a"); | |
a.href = url; | |
a.download = filename || url.split("/").slice(-1)[0]; | |
a.click(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* コッホ雪片 | |
*/ | |
// 設定 | |
/*==========================*/ | |
// 初期座標 | |
var a = {x: 10, y: 580}; | |
var b = {x: 1990, y: 580}; | |
// 描画サイズ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* コピペ防止対策☆ | |
*/ | |
var fakes = [].slice.call(document.getElementsByClassName("lightgray")), fake; | |
while (fake = fakes.shift()) { | |
fake.parentNode.insertBefore(document.createTextNode(" "), fake); | |
fake.parentNode.removeChild(fake); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>mylib</title> | |
</head> | |
<body> | |
<script src="mylib.js" data-mylib="lib"></script> | |
<script> | |
addEventListener("load", function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function F(message) { | |
this.message = message; | |
} | |
F.prototype.print = function () { | |
console.log(this.message); | |
}; | |
// F を継承した G | |
function G(message, name) { | |
F.call(this, message); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Life Game - Cellular Automaton | |
* | |
* Author: Takenori Nakagawa | |
* License: GPLv3 | |
*/ | |
// cell constructor | |
function Cell(x, y, init) { | |
var value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fibonacci = Enumerator.new do |y| | |
i = [0, 1] | |
loop do | |
y << i[0] | |
i = [i[1], i[0] + i[1]] | |
end | |
end | |
# 遅延評価 | |
p fibonacci.lazy.map{|x| x ** 2}.take(20).force |
OlderNewer