CREATE TABLE PRACTICE (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
[GROUP] VARCHAR (30) NOT NULL
DEFAULT ('DEFAULT'),
LABEL VARCHAR (30) NOT NULL,
VALUE INTEGER NOT NULL
);
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
/* | |
* Promiseはモナドじゃないらしいけどモナドっぽく書いてみる試み | |
* 次の3つの「Promiseを返す関数」をつなげてみる | |
* f :: number -> Promise number | |
* g :: number -> Promise string | |
* h :: string -> Promise () | |
*/ | |
const FAILURE_PROBABILITY = 0.1; //一定確率で各プロミスがrejectされるものとする |
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
-- Maybe a (aは任意の型)は「失敗するかもしれない計算」を表す | |
-- f,g,hという3つのMaybeモナド(を返す関数)をつなぐやつ | |
-- f :: Int -> Maybe Int | |
-- g :: Int -> Maybe String | |
-- h :: String -> Maybe () | |
f :: Int -> Maybe Int | |
f n = if n < 10 then Just (n * 3) else Nothing | |
-- *Main> f 3 |
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
with recursive fibb(x,y) as ( | |
select 0,1 | |
union | |
select y,x+y from fibb | |
limit 100 | |
) | |
select x from fibb; |
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
with recursive euclid(x,y) as ( | |
select 56,12 | |
union all | |
select y, x%y from euclid | |
where y != 0 | |
) | |
select x from euclid | |
where y = 0; | |
/* |
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
package main | |
//1 | |
type Vertex struct { | |
X, Y int | |
} | |
//pointer receiver | |
func (v *Vertex) Plus() int { | |
return v.X + v.Y |
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
package main | |
import ( | |
"fmt" | |
"math" | |
"strconv" | |
) | |
func main() { | |
var answers []int |
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
use std::collections::HashSet; | |
fn main() { | |
let mut candidate_count = 0; | |
for i in 1..100000 { | |
if satisfy(i) { | |
candidate_count += 1; | |
println!("Candidate: {}", i.to_string()); | |
} | |
} |
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
// timer機能と、定期的に実行される操作が混ざっている | |
class AutoLottery { | |
constructor(action, interval) { | |
this.action = action; | |
this.interval = interval; | |
this.count = 0; | |
} | |
start() { | |
const execute = () => { | |
this.action(); |
OlderNewer