2021/8/10
[競プロ]
・01-BFS
コストが1となる遷移がどこなのかをしっかりと見ることが重要。
・二部グラフ
026 - Independent Set on a Tree(★4)
[node.js]
・1章の6-> node.jsで簡単なサイコロのアプリを作った。 src/ch1/dice-server.js
・Generator関数は function * 名前() {}で定義する
・非同期処理
Promiseを使って非同期処理が終わるたびにthen()メソッドの中に書いた関数が実行され、ネストを深くするのを避けれるようになっている。
const fs = require('fs')
// Promiseを返す関数を定義(1)
function readFile_pr (fname) {
return new Promise((resolve) => {
resolve(s)
})
})
}
// 順にテキストファイルを読む
readFile_pr('a.txt')
.then((text) => {
console.log('a.txtを読みました', text)
return readFile_pr('b.txt')
})
.then((text) => {
console.log('b.txtを読みました', text)
return readFile_pr('c.txt')
})
.then((text) => {
console.log('c.txtを読みました', text)
})