#『プログラミングの基礎』社内読書会 #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
| (* 目的: 偶数の要素だけ抽出する *) | |
| (* even : int list -> int -> list *) | |
| let rec even xs = | |
| match xs with | |
| [] -> [] | |
| | first :: rest -> | |
| if first mod 2 = 0 | |
| then first :: even rest | |
| else even rest;; |
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
| (* 日付を表現するレコード *) | |
| type date_t = { | |
| month: int; | |
| day: int; | |
| } | |
| (* 人物を表現するレコード *) | |
| type person_t = { | |
| height: float; | |
| weight: float; |
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
| (* 日付を表現するレコード *) | |
| type date_t = { | |
| month: int; | |
| day: int; | |
| } | |
| (* 人物を表現するレコード *) | |
| type person_t = { | |
| name: string; | |
| height: float; |
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
| (* 目的: リストで与えられた文字列を連結する *) | |
| let rec concat xs = | |
| match xs with | |
| [] -> "" | |
| | first :: rest -> first ^ concat rest;; | |
| (* 末尾再帰版の2つの引数を組にしたもの *) | |
| (* インタプリタ上で #trace concat2;; してから実行してみましょう *) | |
| let rec concat2 (xs, out) = | |
| match xs with |
仮想サーバーのプロビジョニングにPython製の Fabric というツールを使います。Pythonを常用していない人は次の手順でPythonならびにFabricを導入してください。
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
| (* 指定されたリストから指定された数の倍数をとりのぞく *) | |
| (* ignore_multiple : int -> int list -> int list *) | |
| let rec ignore_multiple n ns = | |
| match ns with | |
| [] -> [] | |
| | m :: ms -> if m mod n = 0 | |
| then ignore_multiple n ms | |
| else m :: ignore_multiple n ms | |
| (* range : int -> int list *) |
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
| #use "metro.ml" | |
| (* グラフの中の節(駅)を表す型 *) | |
| type eki_t = { | |
| namae : string; (* 駅名(漢字) *) | |
| saitan_kyori : float; (* 最短距離 *) | |
| temae_list : string list; (* 手前の駅名(漢字)のリスト *) | |
| } | |
| let make_eki_list ekimei = |
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
| #!/bin/bash | |
| for h in `grep '^Host\s.*' $1 | awk '{print $2}'`; do | |
| if ssh -F $1 $h : | |
| then | |
| echo $h " - CONNECTED!" | |
| else | |
| echo $h " - FAILED!" | |
| fi | |
| done |
