This file contains hidden or 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
<?php | |
/* | |
* 単純挿入法で配列の値を昇順にソートする | |
*/ | |
$list = array(8, 1, 3, 4, 9, 5); | |
for ($i = 1; $i < count($list); $i++) { | |
$j = $i; |
This file contains hidden or 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 list = [8, 1, 3, 4, 9, 5], | |
j = 1, | |
i, | |
tmp; | |
for (j; j < list.length; j++) { |
This file contains hidden or 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
# encoding: utf-8 | |
# | |
# バブルソートで配列の値を昇順にソートする | |
# | |
list = [8, 1, 3, 4, 9, 5] | |
j = 1 | |
while j < list.size | |
i = j |
This file contains hidden or 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
<?php | |
/* | |
* バブルソートで配列の値を昇順にソートする | |
* | |
*/ | |
$list = array(8, 1, 3, 4, 9, 5); | |
for ($j = 1; $j < count($list);$j++) { | |
for ($i = $j; $i < count($list); $i++) { |
This file contains hidden or 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
/* | |
* 3つの配列から同じ数を見つける | |
*/ | |
// 同じ数 31 | |
var list1 = [2, 6, 10, 16, 24, 31, 38, 40, 50], | |
list2 = [1, 7, 11, 17, 25, 31, 39, 41, 51], | |
list3 = [3, 9, 13, 19, 27, 31, 32, 42, 52], | |
i = 0, | |
j = 0, |
This file contains hidden or 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
# encoding: utf-8 | |
# | |
# 3つの配列から同じ数を見つける | |
# | |
# 同じ数 31 | |
list1 = [2, 6, 10, 16, 24, 31, 38, 40, 50] | |
list2 = [1, 7, 11, 17, 25, 31, 39, 41, 51] | |
list3 = [3, 9, 13, 19, 27, 31, 32, 42, 52] |
This file contains hidden or 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
<?php | |
/* | |
* 3つの配列から同じ数を見つける | |
*/ | |
// 同じ数 31 | |
$list1 = array(2, 6, 10, 16, 24, 31, 38, 40, 50); | |
$list2 = array(1, 7, 11, 17, 25, 31, 39, 41, 51); | |
$list3 = array(3, 9, 13, 19, 27, 31, 32, 42, 52); |
This file contains hidden or 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 list = function(val) { | |
if(!list.cache.hasOwnProperty(val)) { | |
list.cache[val] = val; | |
} | |
return list.cache[val]; | |
} | |
list.cache = {}; | |
list("foo"); | |
list.cache["foo"] == "foo"; |
This file contains hidden or 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 Progress = { | |
count: 0 | |
}; | |
Progress.start = function() { | |
var work = function() { | |
setTimeout(function() { | |
console.log(Progress.count+=1); | |
work(); | |
}, 1000); |
This file contains hidden or 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
<?php | |
class SimpleMock | |
{ | |
public $returnValue = array(); | |
public function __call($method, $args) | |
{ | |
if (isset($this->returnValue[$method])) { | |
return $this->returnValue[$method]; |