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
# -*- coding: utf-8 -*- | |
## | |
## 問題2: シーケンスseqと関数keyを受け取り、要素を値とする辞書を返すような関数 index_by(seq, key) を定義してください。 | |
## 例: | |
## seq = [ {'id': 1, 'name': "Haruhi", 'gender': "F"}, | |
## {'id': 2, 'name': "Mikuru", 'gender': "F"}, | |
## {'id': 3, 'name': "Yuki", 'gender': "F"}, | |
## {'id': 4, 'name': "Ituki", 'gender': "M"}, | |
## {'id': 5, 'name': "Kyon", 'gender': "M"}, |
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
# -*- coding: utf-8 -*- | |
## | |
## 問題3: シーケンスseqと関数keyを受け取り、要素のリストを値とするような辞書を返すような関数 group_by(seq, key) を定義してください。 | |
## 例: | |
## seq = [ {'id': 1, 'name': "Haruhi", 'gender': "F"}, | |
## {'id': 2, 'name': "Mikuru", 'gender': "F"}, | |
## {'id': 3, 'name': "Yuki", 'gender': "F"}, | |
## {'id': 4, 'name': "Ituki", 'gender': "M"}, | |
## {'id': 5, 'name': "Kyon", 'gender': "M"}, |
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
# -*- coding: utf-8 -*- | |
## | |
## 問題4:入れ子になっているリストを、入れ子を外すような関数 flatten(arr) を定義してください。 | |
## 例: | |
## nested = [1, [2, [3, 4], 5, [6]]] | |
## arr = flatten(nested) | |
## print(arr) | |
## #=> [1, 2, 3, 4, 5, 6] | |
## |
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
# -*- coding: utf-8 -*- | |
## | |
## 問題5:入れ子になっているリストを、インデント幅2の文字列に変換する関数 indented(arr, width=2) を定義してください。 | |
## 例: | |
## nested = [1, [2, [3, 4], 5, [6]]] | |
## string = indented(nested) | |
## print(string) | |
## #=> 1 | |
## # 2 |
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
function Company(name, addr) { // Entityクラス | |
this.name = name; | |
this.addr = addr; | |
// | |
this._entity = this; // 姑息な方法 | |
} | |
function Supplier(company) { // Roleクラス | |
this.__proto__ = company; | |
this.products = []; // 商品一覧 (Role固有のデータ) |
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
function Length(value, uom) { | |
this.value = value; | |
this.uom = uom || "cm"; | |
} | |
function Square(length, uom) { | |
this.length = new Length(length, uom); | |
} | |
function Colored(figure, r, g, b) { |
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
// -*- coding: utf-8 -*- | |
// ベースとなる設定 | |
var config_common = { | |
name: 'My Application', | |
mode: null, | |
secret: null, | |
db: { | |
host: 'localhost', | |
port: 9876, |
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
# -*- coding: utf-8 -*- | |
import sys, re | |
from benchmarker import Benchmarker | |
try: | |
xrange | |
except: | |
xrange = range |
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
# -*- coding: utf-8 -*- | |
import sys, re | |
from benchmarker import Benchmarker | |
try: | |
xrange | |
except: | |
xrange = range |
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
# -*- coding: utf-8 -*- | |
import sys, re | |
from benchmarker import Benchmarker | |
try: | |
xrange | |
except: | |
xrange = range |