3 3.1 algebraic datatype data k = 1 1,1... 1,n1 2 2,1... 2,n2... m m,1... m,nm 1 m m m,1,..., m,nm m 1, 2,..., k 1 data Foo x y = Alice x [y] B
|
|
- くにもと よせ
- 4 years ago
- Views:
Transcription
1 3 3.1 algebraic datatype data k = 1 1,1... 1,n1 2 2,1... 2,n2... m m,1... m,nm 1 m m m,1,..., m,nm m 1, 2,..., k 1 data Foo x y = Alice x [y] Bob String y Charlie Foo Double Integer Alice 3.14 [1,2], Bob "Hello" 3, Charlie,... C Java enum 1 data Direction = North South West East 2 deriving (Eq,Ord,Show) North, South, West, East 4 Direction deriving... Q (Rock) (Scissors) (Paper) RPS III - 1
2 1 data Tree a = Empty Branch (Tree a) a (Tree a) 2 deriving (Eq, Ord, Show) Branch Empty 2 Empty Branch Branch Branch :: a Integer String Tree Integer Integer Tree (type constructor) Tree 1 tree1 :: Tree a 2 tree1 = Empty 3 tree2 :: Tree Integer 4 tree2 = Branch Empty 1 Empty 5 tree3 :: Tree String 6 tree3 = Branch (Branch Empty "a" Empty) 7 "b" (Branch Empty "c" Empty) 8 tree4 :: Tree Integer 9 tree4 = Branch (Branch Empty 1 Empty) 10 2 (Branch Empty 3 (Branch Empty 4 Empty)) tree Tree 1 top :: Tree a -> a 2 top (Branch _ a _) = a 3 4 isempty :: Tree a -> Bool 5 isempty Empty = True 6 isempty _ = False 7 8 size :: Tree a -> Integer -- size tree4 4 9 size Empty = 0 10 size (Branch l a r) = size l size r III - 2
3 Q RPS judgerps :: -> Ordering Ordering RPS -> RPS data Ordering = LT EQ GT deriving (Eq, Ord, Bounded, Enum, Read, Show) LT GT Tree depth :: Tree a -> Integer -- preorder :: Tree a -> [a] -- inorder :: Tree a -> [a] -- postorder :: Tree a -> [a] -- reflect :: Tree a -> Tree a -- 1 depth tree4, 2 preorder tree4, 3 inorder tree4, 4 postorder tree4, 5 reflect tree4 1 3, 2 [2,1,3,4], 3 [1,2,3,4], 4 [1,4,3,2], 5 Branch (Branch (Branch Empty 4 Empty) 3 Empty) 2 (Branch Empty 1 Empty) n PL/0 ( books/algorighme0) C data C = F { f1, f2 :: Int, f3 :: Bool } deriving (Eq, Ord, Show) data C = F Int Int Bool deriving (Eq, Ord, Show) = 1 v1 = F { f1 = 5, f2 = 12, f3 = False } 2 3 foo :: C -> Int 4 foo (F { f1 = x, f2 = y }) = x*x + y*y III - 3
4 foo v1 169 v1 f1 v1 5 = v1 { f2 = 3 } F { f1 = 5, f2 = 3, f3 = False } 3.2 ad-hoc dynamic binding, overloading C + int double Haskell 1 : twice x = x + x; x + Haskell 3.3 inheritance encapsulation 3 1 parametric III - 4
5 Q Haskell ML (constructor) (algebraic data type) Java String 3.5 Haskell Haskell Eq Haskell C == Integer Double (\ x -> x+x) == (\ x -> 2*x) Haskell III - 5
6 1 member x [] = False 2 member x (y:ys) = x==y member x ys 3 4 subset xs ys = all (\ x -> member x ys) xs member subset member 5 [1, 4, 7] [Integer] member "Kagawa" ["Tokushima", "Ehime", "Kochi"] [String] member (\ x -> x+x) [\ x -> x+1, \ x -> 2*x] member subset a -> [a] -> Bool [a] -> [a] -> Bool member subset? Scheme Haskell Haskell member subset member :: subset :: Eq a => a Eq type constraint Eq == Haskell Java class Eq Haskell Prelude 1 class Eq a where 2 Java Haskell III - 6
7 2 (==), (/=) :: a -> a -> Bool --!= 3 a /= b = not (a == b) -- a Eq a -> a -> Bool 2 (==), (/=) Direction Eq Direction Eq instance 1 instance Eq Direction where 2 North == North = True 3 South == South = True 4 West == West = True 5 East == East = True 6 _ == _ = False (/=) Tree deriving 1 instance Eq a => Eq (Tree a) where 2 Empty == Empty = True 3 Branch l1 n1 r1 == Branch l2 n2 r2 4 = l1 == l2 && n1 == n2 && r1 == r2 5 _ == _ = False Eq a => Tree a a Tree Eq 2 Eq Q Bool : data MyBool = MyTrue MyFalse Eq Bool Eq III - 7
8 Q Q RPS Eq Q size :: a -> Int Sizable 3.7 Eq Ord, Show, Num 1 class Eq a => Ord a where -- Ord order 2 (<), (<=), (>=), (>) :: a -> a -> Bool 3 max, min :: a -> a -> a class Show a where 7 show :: a -> String class (Eq a, Show a) => Num a where 11 (+), (-), (*) :: a -> a -> a 12 frominteger :: Integer -> a class Num a => Fractional a where 16 (/) :: a -> a -> a Ord Show Num Fractional => Eq Ord Ord Eq III - 8
9 Haskell 1 :: (Num t) => t 3.14 :: (Fractional t) => t 1 Int Double Show, Eq, Ord deriving [diráivin] Haskell 1 data Tree a = Empty Branch (Tree a) a (Tree a) 2 deriving (Eq, Ord, Show) Tree ==, >, show Q data MyList a = MyNil MyCons a (MyList a) deriving Eq Ord Ord Eq == Ord <= : MyList tomylist :: [a] -> MyList a tomylist [] = MyNil tomylist (x:xs) = MyCons x (tomylist xs) tomylist "abc" <= tomylist "abd" -- True tomylist "ab" <= tomylist "abc" -- True tomylist "ab" <= tomylist "a" -- False tomylist "ab" <= tomylist "ba" -- True III - 9
10 3.8 Haskell Haskell Haskell Integer Char [Integer] Show -- let impossible = [1, a,[1,4,7]] -- in map show impossible 3.9 (ambiguity) 1 class Show a where 2 show :: a -> String 3 class Read a where 4 read :: String -> a foo x = show (read x) foo :: (Show a, Read a) => String -> String a => foo x = show (read x :: Integer) a (monomorphism restriction) => III - 10
11 1 genericlength :: Num a => [b] -> a 2 genericlength [] = 0 3 genericlength (_:xs) = 1 + genericlength xs genericlength length :: 1 let v = genericlength [1,2,3,4] 2 in (v,v) [b] -> Int Dictionary-Passing Style 1 \ d1 d2 -> let v d = genericlength d [1,2,3,4] 2 in (v d1, v d2) genericlength DPS 2 2 DPS 1 \ d -> let v = genericlength d [1,2,3,4] 2 in (v, v) 2 v [4] f0 xs = map (+1) xs -- (+1) \ x -> x+1 -- f0 xs = map +1 xs 1 f0 :: (Num (t -> (a -> b) -> [a] -> [b]), 2 Num ((a -> b) -> [a] -> [b])) => 3 t -> (a -> b) -> [a] -> [b] 1 -- (-1) 2 -- f1 xs = map (\ x -> x-1) xs 3 f1 xs = map (-1) xs : III - 11
12 6 -- f2 n = n : [4,5,6] 7 f2 n = [n] : [4,5,6] Haskell f. g = \ x -> f (g x) f3 r = r * sin f3 r = r * sin.2 Q f1, f2, f Dictionary-Passing Style Haskell Haskell 1 type Eq a = 2 3 eq :: Eq a -> (a -> a -> Bool) 4 eq = \ (e, _) -> e -- (==) 5 6 ne :: Eq a -> (a -> a -> Bool) 7 ne = \ (_, n) -> n -- (/=) Eq a method dictionary 1 eqdirectiondic :: Eq Direction 2 eqdirectiondic = (eqdirection, \ a b -> not (a eqdirection b)) 3 where North eqdirection North = True 4 South eqdirection South = True 5 West eqdirection West = True 6 East eqdirection East = True 7 _ eqdirection _ = False III - 12
13 8 9 eqtreedic :: Eq a -> Eq (Tree a) 10 eqtreedic (eqa, _) = (eqtree, \ a b -> not (eqtree a b)) 11 where Empty eqtree Empty = True 12 Branch l1 n1 r1 eqtree Branch l2 n2 r2 13 = l1 eqtree l2 && n1 eqa n2 && r1 eqtree r2 14 _ eqtree _ = False... =>... Eq a 1 member :: -> a -> [a] -> Bool 2 member d x [] = False 3 member d x (y:ys) = eq d x y member d x ys 4 5 subset :: -> [a] -> [a] -> Bool 6 subset d xs ys = all (\ x -> member d x ys) xs member North [North, South, West] member North [North, South, West] subset [North, South] [North, South, West] subset [North, South] [North, South, West] Dictionary-Passing Style Haskell lookup: 1 data Maybe a = Just a Nothing 2 3 lookup :: Eq a => a -> [(a, b)] -> Maybe b 4 lookup x ((n,v):rest) = if n==x then Just v else lookup x rest 5 lookup x [] = Nothing lookup Dictionary-Passing Style lookupd: lookupd :: Eq a -> a -> [(a, b)] -> Maybe b lookup 1 [(1,2),(4,7)] lookupd eqintdic 1 [(1,2),(4,7)] lookup 1.1 [(1.4,0.1),(4.2,6.9)] 3 III - 13
14 lookupd eqdoubledic 1.1 [(1.4,0.1),(4.2,6.9)] eqintdic, eqdoubledic 3.11 Smalltalk [5] 6 JavaScript prototype Self JavaScript [6] 6 JavaScript Common Lisp CLOS multi-method 2 Java char, int double Scala C# Smalltalk[5], CLOS, JavaScript[6], C++, Java[7], Python, Ruby 3.12 Haskell III - 14
15 [1] [2] Haskell [3] Haskell Haskell [4] [1] Philip Wadler and Stephen Blott How to make ad-hoc polymorphism less adhoc Conference Record of the Sixteenth Annual ACM Symposium on Principles of Programming Languages, pp [2] Cordelia Hall, Kevin Hammond, Simon Peyton Jones and Philip Wadler Type Classes in Haskell 1996 ACM Transactions on Programming Languages and Systems 18 2, pp [3] Mark P. Jones Typing Haskell in Haskell mpj/thih/ [4] Bastiaan Heeren and Jurriaan Hage Type Class Directives Seventh International Symposium on Practical Aspects of Declarative Languages (LNCS 3350), pp [5] Mark Guzdial and Kim Rose Squeak [6] JavaScript ASCII [7] Tim Lindholm and Frank Yellin Java III - 15
16
org/ghc/ Windows Linux RPM 3.2 GHCi GHC gcc javac ghc GHCi(ghci) GHCi Prelude> GHCi :load file :l file :also file :a file :reload :r :type expr :t exp
3 Haskell Haskell Haskell 1. 2. 3. 4. 5. 1. 2. 3. 4. 5. 6. C Java 3.1 Haskell Haskell GHC (Glasgow Haskell Compiler 1 ) GHC Haskell GHC http://www.haskell. 1 Guarded Horn Clauses III - 1 org/ghc/ Windows
More informationhaskell.gby
Haskell 1 2 3 Haskell ( ) 4 Haskell Lisper 5 Haskell = Haskell 6 Haskell Haskell... 7 qsort [8,2,5,1] [1,2,5,8] "Hello, " ++ "world!" "Hello, world!" 1 + 2 div 8 2 (+) 1 2 8 div 2 3 4 map even [1,2,3,4]
More information第9回 型とクラス
1 関数型プログラミング 第 9 回型とクラス 萩野達也 hagino@sfc.keio.ac.jp 2 静的型検査と型推論 型 値の集合 Bool = { True, False } Char = { 'a', 'b',... } Int = {... -2, -1, 0, 1, 2, 3,... } 静的型検査 Haskell はコンパイル時に式の型を検査する 静的 = コンパイル時 (v.s.
More informationCopyright c 2008 Zhenjiang Hu, All Right Reserved.
2008 10 27 Copyright c 2008 Zhenjiang Hu, All Right Reserved. (Bool) True False data Bool = False True Remark: not :: Bool Bool not False = True not True = False (Pattern matching) (Rewriting rules) not
More informationParametric Polymorphism
ML 2 2011/04/19 Parametric Polymorphism Type Polymorphism ? : val hd_int : int list - > int val hd_bool : bool list - > bool val hd_i_x_b : (int * bool) list - > int * bool etc. let hd_int = function (x
More informationfp.gby
1 1 2 2 3 2 4 5 6 7 8 9 10 11 Haskell 12 13 Haskell 14 15 ( ) 16 ) 30 17 static 18 (IORef) 19 20 OK NG 21 Haskell (+) :: Num a => a -> a -> a sort :: Ord a => [a] -> [a] delete :: Eq a => a -> [a] -> [a]
More information2
2011.11.11 1 2 MapReduce 3 4 5 6 Functional Functional Programming 7 8 9 10 11 12 13 [10, 20, 30, 40, 50] 0 n n 10 * 0 + 20 * 1 + 30 * 2 + 40 * 3 + 50 *4 = 400 14 10 * 0 + 20 * 1 + 30 * 2 + 40 * 3 + 50
More information2011.12.3 1 2 Q) A) 3 Q) A) 4 5 6 Haskell 7 8 Parser data Parser a = Parser (String -> [(a,string)]) Parser pwrap :: a -> Parser a pwrap v = Parser $ \inp -> [(v,inp)] Parser pbind :: Parser a -> (a ->
More informationmonad.gby
2012.11.18 1 1 2 2 DSL 3 4 Q) A) 5 Q) A) 6 7 8 Haskell 9 10 Parser data Parser a = Parser (String -> [(a,string)]) Parser pwrap :: a -> Parser a pwrap v = Parser $ \inp -> [(v,inp)] Parser pbind :: Parser
More informationFunctional Programming
PROGRAMMING IN HASKELL プログラミング Haskell Chapter 10 - Declaring Types and Classes 型とクラスの定義 愛知県立大学情報科学部計算機言語論 ( 山本晋一郎 大久保弘崇 2011 年 ) 講義資料オリジナルは http://www.cs.nott.ac.uk/~gmh/book.html を参照のこと 0 型宣言 (Type Declarations)
More information連載 構文解析器結合子 山下伸夫 (( 株 ) タイムインターメディア ) 文字列の分解 1 1 Haskell lines Prelude lines :: String -> [String] lines "" = [] lines s = let (l,s'
連載 構文解析器結合子 山下伸夫 (( 株 ) タイムインターメディア ) nobsun@sampou.org 文字列の分解 1 1 Haskell lines Prelude lines :: String -> [String] lines "" = [] lines s = let (l,s') = break ('\n'==) s in l : case s' of [] -> [] (_:s'')
More information# let st1 = {name = "Taro Yamada"; id = };; val st1 : student = {name="taro Yamada"; id=123456} { 1 = 1 ;...; n = n } # let string_of_student {n
II 6 / : 2001 11 21 (OCaml ) 1 (field) name id type # type student = {name : string; id : int};; type student = { name : string; id : int; } student {} type = { 1 : 1 ;...; n : n } { 1 = 1 ;...; n = n
More information6-1
6-1 (data type) 6-2 6-3 ML, Haskell, Scala Lisp, Prolog (setq x 123) (+ x 456) (setq x "abc") (+ x 456) ; 6-4 ( ) subtype INDEX is INTEGER range -10..10; type DAY is (MON, TUE, WED, THU, FRI, SAT, SUN);
More information2
Haskell ( ) kazu@iij.ad.jp 1 2 Blub Paul Graham http://practical-scheme.net/trans/beating-the-averages-j.html Blub Blub Blub Blub 3 Haskell Sebastian Sylvan http://www.haskell.org/haskellwiki/why_haskell_matters...
More informationCopyright c 2006 Zhenjiang Hu, All Right Reserved.
1 2006 Copyright c 2006 Zhenjiang Hu, All Right Reserved. 2 ( ) 3 (T 1, T 2 ) T 1 T 2 (17.3, 3) :: (Float, Int) (3, 6) :: (Int, Int) (True, (+)) :: (Bool, Int Int Int) 4 (, ) (, ) :: a b (a, b) (,) x y
More informationコンパイラ演習 第 7 回
コンパイラ演習 第 7 回 (2010/11/18) 秋山茂樹池尻拓朗前田俊行鈴木友博渡邊裕貴潮田資秀小酒井隆広山下諒蔵佐藤春旗大山恵弘佐藤秀明住井英二郎 今日の内容 Type Polymorphism ( 型多相性 ) の実現について Polymorphism 大きく分けて 3 種類ある Parametric polymorphism Subtyping polymorphism Ad-hoc polymorphism
More informationbdd.gby
Haskell Behavior Driven Development 2012.5.27 @kazu_yamamoto 1 Haskell 4 Mew Firemacs Mighty ghc-mod 2 Ruby/Java HackageDB 3 Haskeller 4 Haskeller 5 Q) Haskeller A) 6 7 Haskeller Haskell 8 9 10 Haskell
More informationtest.gby
Beautiful Programming Language and Beautiful Testing 1 Haskeller Haskeller 2 Haskeller (Doctest QuickCheck ) github 3 Haskeller 4 Haskell Platform 2011.4.0.0 Glasgow Haskell Compiler + 23 19 8 5 10 5 Q)
More informationpresen.gby
kazu@iij.ad.jp 1 2 Paul Graham 3 Andrew Hunt and David Thomas 4 5 Java 6 Java Java Java 3 7 Haskell Scala Scala 8 9 Java Java Dean Wampler AWT ActionListener public interface ActionListener extends EventListener
More information5 IO Haskell return (>>=) Haskell Haskell Haskell 5.1 Util Util (Util: Tiny Imperative Language) 1 UtilErr, UtilST, UtilCont, Haskell C
5 IO Haskell return (>>=) Haskell Haskell Haskell 5.1 Util Util (Util: Tiny Imperative Language) 1 UtilErr, UtilST, UtilCont,... 5.1.1 5.1.2 Haskell C LR ( ) 1 (recursive acronym) PHP, GNU V - 1 5.1.1
More information(CC Attribution) Lisp 2.1 (Gauche )
http://www.flickr.com/photos/dust/3603580129/ (CC Attribution) Lisp 2.1 (Gauche ) 2 2000EY-Office 3 4 Lisp 5 New York The lisps Sammy Tunis flickr lisp http://www.flickr.com/photos/dust/3603580129/ (CC
More informationkyoto.gby
Haskell 2013.5.24 1 2 1988 B4 Sun 1992 3 Unix Magazine Unix Magazine UNIX RFC FYI (For Your Information) 4 IP PEM (Privacy Enhanced Mail) WIDE Project mh-e PEM 5 6 Unix Magazine PGP PGP 1 7 Mew (MIME)
More information10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV
tutimura@mist.i.u-tokyo.ac.jp kaneko@ipl.t.u-tokyo.ac.jp http://www.misojiro.t.u-tokyo.ac.jp/ tutimura/sem3/ 2002 12 11 p.1/33 10/16 1. 10/23 2. 10/30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20
More information第12回 モナドパーサ
1 関数型プログラミング 第 13 回モナドパーサ 萩野達也 hagino@sfc.keio.ac.jp Slide URL https://vu5.sfc.keio.ac.jp/slide/ 2 モナドパーサ モナドを使って構文解析を行ってみましょう. data Parser a = Parser (String -> Maybe (a, String)) 字句解析も構文解析の一部に含めてしまいます.
More informationパズルをSugar制約ソルバーで解く
Sugar 1 2 3 1 CSPSAT 2008 8 21 Sugar 1 2 3 Sugar Sugar (CSP) (SAT ) (encode) SAT SAT order encoding direct encoding support encoding http://bachistckobe-uacjp/sugar/ Web Sugar 1 2 3 Sugar SAT (COP) MAX-CSP
More information¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~alse
I Exercise on Programming I http://bit.ly/oitprog1 1, 2 of 14 ( RD S ) I 1, 2 of 14 1 / 44 Ruby Ruby ( RD S ) I 1, 2 of 14 2 / 44 7 5 9 2 9 3 3 2 6 5 1 3 2 5 6 4 7 8 4 5 2 7 9 6 4 7 1 3 ( RD S ) I 1, 2
More informationML Edinburgh LCF ML Curry-Howard ML ( ) ( ) ( ) ( ) 1
More Logic More Types ML/OCaml GADT Jacques Garrigue ( ) Jacques Le Normand (Google) Didier Rémy (INRIA) @garriguejej ocamlgadt ML Edinburgh LCF ML Curry-Howard ML ( ) ( ) ( ) ( ) 1 ( ) ML type nebou and
More information# let rec sigma (f, n) = # if n = 0 then 0 else f n + sigma (f, n-1);; val sigma : (int -> int) * int -> int = <fun> sigma f n ( : * -> * ) sqsum cbsu
II 4 : 2001 11 7 keywords: 1 OCaml OCaml (first-class value) (higher-order function) 1.1 1 2 + 2 2 + + n 2 sqsum 1 3 + 2 3 + + n 3 cbsum # let rec sqsum n = # if n = 0 then 0 else n * n + sqsum (n - 1)
More informationcpp1.dvi
2017 c 1 C++ (1) C C++, C++, C 11, 12 13 (1) 14 (2) 11 1 n C++ //, [List 11] 1: #include // C 2: 3: int main(void) { 4: std::cout
More informationEmacs ML let start ::= exp (1) exp ::= (2) fn id exp (3) ::= (4) (5) ::= id (6) const (7) (exp) (8) let val id = exp in
Emacs, {l06050,sasano}@sic.shibaura-it.ac.jp Eclipse Visual Studio Standard ML Haskell Emacs 1 Eclipse Visual Studio variable not found LR(1) let Emacs Emacs Emacs Java Emacs JDEE [3] JDEE Emacs Java 2
More informationFunctional Programming
PROGRAMMING IN HASKELL プログラミング Haskell Chapter 7 - Higher-Order Functions 高階関数 愛知県立大学情報科学部計算機言語論 ( 山本晋一郎 大久保弘崇 2013 年 ) 講義資料オリジナルは http://www.cs.nott.ac.uk/~gmh/book.html を参照のこと 0 Introduction カリー化により
More informationプログラミングD - Java
プログラミング D 講義資料 中田明夫 nakata@ist.osaka-u.ac.jp ML 教科書 プログラミング言語 Standard ML 入門 :1,2 章 講義のねらい 関数型プログラムを知る 関数型プログラムを知る利点 プログラムを統一的, 抽象的に捕らえる リスト処理, 高階関数, 再帰関数定義 リストやツリーなどのデータ構造は再帰的に定義 再帰関数で扱うとプログラミングが容易 数学的な裏付け
More informationshift/reset [13] 2 shift / reset shift reset k call/cc reset shift k shift (...) k 1 + shift(fun k -> 2 * (k 3)) k 2 * (1 + 3) 8 reset shift reset (..
arisa@pllab.is.ocha.ac.jp asai@is.ocha.ac.jp shift / reset CPS shift / reset CPS CPS 1 [3, 5] goto try/catch raise call/cc [17] control/prompt [8], shift/reset [5] control/prompt, shift/reset call/cc (continuationpassing
More information2002.N.x.h.L.......g9/20
1 2 3 4 5 6 1 2 3 4 5 8 9 1 11 11 12 13 k 14 l 16 m 17 n 18 o 19 k 2 l 2 m 21 n 21 o 22 p 23 q 23 r 24 24 25 26 27 28 k 28 l 29 m 29 3 31 34 42 44 1, 8, 6, 4, 2, 1,2 1, 8 6 4 2 1, 8, 6, 4, 2, 1,2 1, 8
More information新たな基礎年金制度の構築に向けて
[ ] 1 1 4 60 1 ( 1 ) 1 1 1 4 1 1 1 1 1 4 1 2 1 1 1 ( ) 2 1 1 1 1 1 1 1996 1 3 4.3(2) 1997 1 65 1 1 2 1/3 ( )2/3 1 1/3 ( ) 1 1 2 3 2 4 6 2.1 1 2 1 ( ) 13 1 1 1 1 2 2 ( ) ( ) 1 ( ) 60 1 1 2.2 (1) (3) ( 9
More informationInt Int 29 print Int fmt tostring 2 2 [19] ML ML [19] ML Emacs Standard ML M M ::= x c λx.m M M let x = M in M end (M) x c λx.
1, 2 1 m110057@shibaura-it.ac.jp 2 sasano@sic.shibaura-it.ac.jp Eclipse Visual Studio ML Standard ML Emacs 1 ( IDE ) IDE C C++ Java IDE IDE IDE IDE Eclipse Java IDE Java Standard ML 1 print (Int. 1 Int
More information: gettoken(1) module P = Printf exception End_of_system (* *) let _ISTREAM = ref stdin let ch = ref ( ) let read () = (let c =!ch in ch := inp
7 OCaml () 1. 2. () (compiler) (interpreter) 2 OCaml (syntax) (BNF,backus normal form ) 1 + 2; let x be 2-1 in x; ::= ; let be in ; ::= + - ::= * / ::= 7.1 ( (printable characters) (tokens) 1 (lexical
More informationohp02.dvi
172 2017.7.16 1 ? X A B A X B ( )? IBMPL/I FACOM PL1 ( ) X 2 ( ) 3 2-0 ( ) ( ) ( ) (12) ( ) (112) 31) 281 26 1 4 (syntax) (semantics) ( ) 5 BNF BNF(Backus Normal Form) Joun Backus (grammer) English grammer
More informationML λ λ 1 λ 1.1 λ λ λ e (λ ) ::= x ( ) λx.e (λ ) e 1 e 2 ( ) ML λx.e Objective Caml fun x -> e x e let 1
2005 sumii@ecei.tohoku.ac.jp 2005 6 24 ML λ λ 1 λ 1.1 λ λ λ e (λ ) ::= x ( ) λx.e (λ ) e 1 e 2 ( ) ML λx.e Objective Caml fun x -> e x e let 1 let λ 1 let x = e1 in e2 (λx.e 2 )e 1 e 1 x e 2 λ 3 λx.(λy.e)
More informationclass IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =
Part2-1-3 Java (*) (*).class Java public static final 1 class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value
More information導入基礎演習.ppt
Multi-paradigm Programming Functional Programming Scheme Haskell ML Scala X10 KL1 Prolog Declarative Lang. C Procedural Lang. Java C++ Python Object-oriented Programming / (root) bin home lib 08 09
More information解きながら学ぶJava入門編
44 // class Negative { System.out.print(""); int n = stdin.nextint(); if (n < 0) System.out.println(""); -10 Ÿ 35 Ÿ 0 n if statement if ( ) if i f ( ) if n < 0 < true false true false boolean literalboolean
More information記号と準備
tbasic.org * 1 [2017 6 ] 1 2 1.1................................................ 2 1.2................................................ 2 1.3.............................................. 3 2 5 2.1............................................
More information福岡大学人文論叢47-3
679 pp. 1 680 2 681 pp. 3 682 4 683 5 684 pp. 6 685 7 686 8 687 9 688 pp. b 10 689 11 690 12 691 13 692 pp. 14 693 15 694 a b 16 695 a b 17 696 a 18 697 B 19 698 A B B B A B B A A 20 699 pp. 21 700 pp.
More information¿ô³Ø³Ø½øÏÀ¥Î¡¼¥È
2011 i N Z Q R C A def B, A B. ii..,.,.. (, ), ( ),.?????????,. iii 04-13 04-20 04-27 05-04 [ ] 05-11 05-18 05-25 06-01 06-08 06-15 06-22 06-29 07-06 07-13 07-20 07-27 08-03 10-05 10-12 10-19 [ ] 10-26
More information2 objective 1 2.1 m a ( ) Haskell Rank2Types 2 newtype Object f g = Object { runobject :: forall a. f a -> g (a, Object f g) } 1 a g a Functor g a ::
Haskell 1, 2 fumiexcel@gmail.com 2 IIJ kazu@iij.ad.jp Haskell Haskell Haskell 1 Haskell[1] Haskell [2] Haskell ( OOPL) GUI Haskell Haskell OOPL OOPL [3, 4] ( OOP) [5] OOP Haskell OOPL Haskell Java C++
More informationr02.dvi
172 2017.7.16 1 1.1? X A B A X B ( )? IBMPL/I FACOM PL1 ( ) X ( ) 1.2 1 2-0 ( ) ( ) ( ) (12) ( ) (112) (131) 281 26 1 (syntax) (semantics) ( ) 2 2.1 BNF BNF(Backus Normal Form) Joun Backus (grammer) English
More informationuntitled
II 4 Yacc Lex 2005 : 0 1 Yacc 20 Lex 1 20 traverse 1 %% 2 [0-9]+ { yylval.val = atoi((char*)yytext); return NUM; 3 "+" { return + ; 4 "*" { return * ; 5 "-" { return - ; 6 "/" { return / ; 7 [ \t] { /*
More informationBASIC / / BA- SIC Web 1/10 1/10 / / JavaScript
BASIC / / BA- SIC Web 1/10 1/10 // JavaScript MIT Processing line(10,10,100,100); 1 BASIC / Phidgets 1 GAINER 2 USB / Phidgets USB 1: 1 http://www.phidgets.com/ 2 http://gainer.cc/ / / BGM Phidgets University
More informationkoba/class/soft-kiso/ 1 λ if λx.λy.y false 0 λ typed λ-calculus λ λ 1.1 λ λ, syntax τ (types) ::= b τ 1 τ 2 τ 1
http://www.kb.ecei.tohoku.ac.jp/ koba/class/soft-kiso/ 1 λ if λx.λy.y false 0 λ typed λ-calculus λ λ 1.1 λ 1.1.1 λ, syntax τ (types) ::= b τ 1 τ 2 τ 1 τ 2 M (terms) ::= c τ x M 1 M 2 λx : τ.m (M 1,M 2
More information(Basic Theory of Information Processing) Fortran Fortan Fortan Fortan 1
(Basic Theory of Information Processing) Fortran Fortan Fortan Fortan 1 17 Fortran Formular Tranlator Lapack Fortran FORTRAN, FORTRAN66, FORTRAN77, FORTRAN90, FORTRAN95 17.1 A Z ( ) 0 9, _, =, +, -, *,
More information6 29 6.1.............................. 29 6.2.............................. 31 6.3.... 33 7 34 7.1 Cocos2d-x..................... 35 7.2..............
1 3 1.1.............................. 3 1.2........................ 3 2 4 2.1.................. 4 2.2.............................. 5 2.2.1.......................... 6 2.2.2.......................... 7
More informationclass IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =
Part2-1-3 Java (*) (*).class Java public static final 1 class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value
More informationLIFO(last in first out, ) 1 FIFO(first in first out, ) 2 2 PUSH POP : 1
2007 7 17 2 1 1.1 LIFO(last in first out, ) 1 FIFO(first in first out, ) 2 2 PUSH POP 2 2 5 5 5 1: 1 2 データの追加 データの取り出し 5 2 5 2 5 2: 1.2 [1] pp.199 217 2 (binary tree) 2 2.1 (three: ) ( ) 秋田高専 校長 準学士課程学生
More information「計算と論理」 Software Foundations その4
Software Foundations 4 cal17@fos.kuis.kyoto-u.ac.jp http://www.fos.kuis.kyoto-u.ac.jp/~igarashi/class/cal/ November 7, 2017 ( ) ( 4) November 7, 2017 1 / 51 Poly.v ( ) ( 4) November 7, 2017 2 / 51 : (
More informationdouble float
2015 3 13 1 2 2 3 2.1.......................... 3 2.2............................. 3 3 4 3.1............................... 4 3.2 double float......................... 5 3.3 main.......................
More information1 # include < stdio.h> 2 # include < string.h> 3 4 int main (){ 5 char str [222]; 6 scanf ("%s", str ); 7 int n= strlen ( str ); 8 for ( int i=n -2; i
ABC066 / ARC077 writer: nuip 2017 7 1 For International Readers: English editorial starts from page 8. A : ringring a + b b + c a + c a, b, c a + b + c 1 # include < stdio.h> 2 3 int main (){ 4 int a,
More information1.
3 ( ) 1. n Tiny C n yacc (bison) lex (flex) n IA n n n n n n (lex ) 50 (yacc ) 400 200 550 n n yacc/lex TA Tiny C n C n int n (if, while) int fact(int n) {! if (n == 1) return 1;! else return n * fact(n-1);!
More informationr03.dvi
19 ( ) 019.4.0 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void... argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0 a a \0 b b b \0 c c c \0 1: // argdemo1.c ---
More information応用数学特論.dvi
1 1 1.1.1 ( ). P,Q,R,.... 2+3=5 2 1.1.2 ( ). P T (true) F (false) T F P P T P. T 2 F 1.1.3 ( ). 2 P Q P Q P Q P Q P or Q P Q P Q P Q T T T T F T F T T F F F. P = 5 4 Q = 3 2 P Q = 5 4 3 2 P F Q T P Q T
More information「計算と論理」 Software Foundations その3
Software Foundations 3 cal17@fos.kuis.kyoto-u.ac.jp October 24, 2017 ( ) ( 3) October 24, 2017 1 / 47 Lists.v ( ) ( ) ( ) ( 3) October 24, 2017 2 / 47 ( ) Inductive natprod : Type := pair : nat nat natprod.
More information1
005 11 http://www.hyuki.com/girl/ http://www.hyuki.com/story/tetora.html http://www.hyuki.com/ Hiroshi Yuki c 005, All rights reserved. 1 1 3 (a + b)(a b) = a b (x + y)(x y) = x y a b x y a b x y 4 5 6
More informationRuby Ruby ruby Ruby G: Ruby>ruby Ks sample1.rb G: Ruby> irb (interactive Ruby) G: Ruby>irb -Ks irb(main):001:0> print( ) 44=>
Ruby Ruby 200779 ruby Ruby G: Ruby>ruby Ks sample1.rb G: Ruby> irb (interactive Ruby) G: Ruby>irb -Ks irb(main):001:0> print( 2+3+4+5+6+7+8+9 ) 44 irb(main):002:0> irb irb(main):001:0> 1+2+3+4 => 10 irb(main):002:0>
More informationohp03.dvi
19 3 ( ) 2019.4.20 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void int main(int argc, char *argv[]) {... 2 (2) argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0
More information, 1. x 2 1 = (x 1)(x + 1) x 3 1 = (x 1)(x 2 + x + 1). a 2 b 2 = (a b)(a + b) a 3 b 3 = (a b)(a 2 + ab + b 2 ) 2 2, 2.. x a b b 2. b {( 2 a } b )2 1 =
x n 1 1.,,.,. 2..... 4 = 2 2 12 = 2 2 3 6 = 2 3 14 = 2 7 8 = 2 2 2 15 = 3 5 9 = 3 3 16 = 2 2 2 2 10 = 2 5 18 = 2 3 3 2, 3, 5, 7, 11, 13, 17, 19.,, 2,.,.,.,?.,,. 1 , 1. x 2 1 = (x 1)(x + 1) x 3 1 = (x 1)(x
More informationii
I05-010 : 19 1 ii k + 1 2 DS 198 20 32 1 1 iii ii iv v vi 1 1 2 2 3 3 3.1.................................... 3 3.2............................. 4 3.3.............................. 6 3.4.......................................
More informationK227 Java 2
1 K227 Java 2 3 4 5 6 Java 7 class Sample1 { public static void main (String args[]) { System.out.println( Java! ); } } 8 > javac Sample1.java 9 10 > java Sample1 Java 11 12 13 http://java.sun.com/j2se/1.5.0/ja/download.html
More informationN88 BASIC 0.3 C: My Documents 0.6: 0.3: (R) (G) : enterreturn : (F) BA- SIC.bas 0.8: (V) 0.9: 0.5:
BASIC 20 4 10 0 N88 Basic 1 0.0 N88 Basic..................................... 1 0.1............................................... 3 1 4 2 5 3 6 4 7 5 10 6 13 7 14 0 N88 Basic 0.0 N88 Basic 0.1: N88Basic
More information1-4 int a; std::cin >> a; std::cout << "a = " << a << std::endl; C++( 1-4 ) stdio.h iostream iostream.h C++ include.h 1-4 scanf() std::cin >>
1 C++ 1.1 C C++ C++ C C C++ 1.1.1 C printf() scanf() C++ C hello world printf() 1-1 #include printf( "hello world\n" ); C++ 1-2 std::cout
More information"-./0%. "-%!"#$#% $%&'(%)*+,%.!"#+$,$% &'()*% $%&'-(.(/%+,% $%&'0%12*+,'% 1 RMX.. grade gradetype= integer grade[
DEIM Forum 2014 C8-5 RMX 223 8522 3 14 1 E-mail: {yohei,kita}@db.ics.keio.ac.jp, toyama@ics.keio.ac.jp RMX,,, RMX., RMX, RMX,., RMX,., RMX,.,,., RMX 1. RMX (Rule-based e-mail exchange System).,,., RMX,
More informationld-2.dvi
Ld-2 Common Lisp TR-98-19 1998 8 19 1 3 2 4 2.1 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 4 2.2 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
More informationr1.dvi
2006 1 2006.10.6 ( 2 ( ) 1 2 1.5 3 ( ) Ruby Java Java Java ( Web Web http://lecture.ecc.u-tokyo.ac.jp/~kuno/is06/ / ( / @@@ ( 3 ) @@@ : ( ) @@@ (Q&A) ( ) 1 http://www.sodan.ecc.u-tokyo.ac.jp/cgi-bin/qbbs/view.cgi
More informationJava updated
Java 2003.07.14 updated 3 1 Java 5 1.1 Java................................. 5 1.2 Java..................................... 5 1.3 Java................................ 6 1.3.1 Java.......................
More informationuntitled
II yacc 005 : 1, 1 1 1 %{ int lineno=0; 3 int wordno=0; 4 int charno=0; 5 6 %} 7 8 %% 9 [ \t]+ { charno+=strlen(yytext); } 10 "\n" { lineno++; charno++; } 11 [^ \t\n]+ { wordno++; charno+=strlen(yytext);}
More informationJava Java Java Java Java 4 p * *** ***** *** * Unix p a,b,c,d 100,200,250,500 a*b = a*b+c = a*b+c*d = (a+b)*(c+d) = 225
Java Java Java Java Java 4 p35 4-2 * *** ***** *** * Unix p36 4-3 a,b,c,d 100,200,250,500 a*b = 20000 a*b+c = 20250 a*b+c*d = 145000 (a+b)*(c+d) = 225000 a+b*c+d = 50600 b/a+d/c = 4 p38 4-4 (1) mul = 1
More informationMilner Harper LCF ML HOPE (type inference) news letter Polymorphism [28] [30, 24, 13] 3 Standard ML 1990 ML LCF ML The Definition of Standard ML[31] L
1 ML ML (Meta Langauge) ML ML LCF LCF (proof ML tactics) ML (higher-order functions) LCF ML ML ML 2 ML 3 ML LCF 4 ML 5 ML Lisp Scheme 6 LCF ML ML 2 ML ML 1970 Edinburgh Edinburgh LCF [12] LCF LCF ML Robin
More information情報科学概論 第1回資料
1. Excel (C) Hiroshi Pen Fujimori 1 2. (Excel) 2.1 Excel : 2.2Excel Excel (C) Hiroshi Pen Fujimori 2 256 (IV) :C (C 65536 B4 :2 (2 A3 Excel (C) Hiroshi Pen Fujimori 3 Tips: (1) B3 (2) (*1) (3) (4)Word
More information第10回 モジュール
1 FUNCTIONAL PROGRAMMING 第 10 回モジュール 萩野達也 hagino@sfc.keio.ac.jp 2 モジュール モジュールは以下のエンティティを含みます. 変数 型コンストラクタ データコンストラクタ フィールドラベル 型クラス クラスメソッド Java のパッケージに似ている 名前空間はモジュールごとに分かれている 名前 ( 識別子 ) はモジュールで一意的でなくてはいけない
More informationf(x) x S (optimal solution) f(x ) (optimal value) f(x) (1) 3 GLPK glpsol -m -d -m glpsol -h -m -d -o -y --simplex ( ) --interior --min --max --check -
GLPK by GLPK http://mukun mmg.at.infoseek.co.jp/mmg/glpk/ 17 7 5 : update 1 GLPK GNU Linear Programming Kit GNU LP/MIP ILOG AMPL(A Mathematical Programming Language) 1. 2. 3. 2 (optimization problem) X
More information0 1 1 @master q 3 1.1.......................................... 3 1.2....................................... 4 1.3....................................
1 0!? Q.? A. Q. B. Q.? A.! 2 10 6 Scheme 80! λ 81!? λ ( ) 82!? λ ( ) 83!? λ 4 3! λ 0 1 1 @master q 3 1.1.......................................... 3 1.2....................................... 4 1.3............................................
More informationSystemC 2.0を用いた簡易CPUバスモデルの設計
SystemC 2.0 CPU CPU CTD&SW CT-PF 2002/1/23 1 CPU BCA UTF GenericCPU IO (sc_main) 2002/1/23 2 CPU CPU CQ 1997 11 Page 207 4 Perl Verilog-HDL CPU / Verilog-HDL SystemC 2.0 (asm) ROM (test.hex) 2002/1/23
More information2
1 2 119 119 5 500 1 30 102 1 113 3 4 120 2 3 113 5 230 1 1 3 4 5 6 7 8 1 support@kansen.sakura.ne.jp 2 9 3 ( ) 10 11 12 4 1. 2. 3. 4. 13 5 14 15 16 17 18 19 [ ] [ ] 20 [ ] [ ] [ ] 21 22 [ ] 23 < > < >
More informationCondition DAQ condition condition 2 3 XML key value
Condition DAQ condition 2009 6 10 2009 7 2 2009 7 3 2010 8 3 1 2 2 condition 2 3 XML key value 3 4 4 4.1............................. 5 4.2...................... 5 5 6 6 Makefile 7 7 9 7.1 Condition.h.............................
More informationex01.dvi
,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) double
More information2 1/2 1/4 x 1 x 2 x 1, x 2 9 3x 1 + 2x 2 9 (1.1) 1/3 RDA 1 15 x /4 RDA 1 6 x /6 1 x 1 3 x 2 15 x (1.2) (1.3) (1.4) 1 2 (1.5) x 1
1 1 [1] 1.1 1.1. TS 9 1/3 RDA 1/4 RDA 1 1/2 1/4 50 65 3 2 1/15 RDA 2/15 RDA 1/6 RDA 1 1/6 1 1960 2 1/2 1/4 x 1 x 2 x 1, x 2 9 3x 1 + 2x 2 9 (1.1) 1/3 RDA 1 15 x 1 + 2 1/4 RDA 1 6 x 1 1 4 1 1/6 1 x 1 3
More information4 (induction) (mathematical induction) P P(0) P(x) P(x+1) n P(n) 4.1 (inductive definition) A A (basis ) ( ) A (induction step ) A A (closure ) A clos
4 (induction) (mathematical induction) P P(0) P(x) P(x+1) n P(n) 4.1 (inductive definition) A A (basis ) ( ) A (induction step ) A A (closure ) A closure 81 3 A 3 A x A x + A A ( A. ) 3 closure A N 1,
More information2 static final int DO NOTHING ON CLOSE static final int HIDE ON CLOSE static final int DISPOSE ON CLOSE static final int EXIT ON CLOSE void setvisible
12 2013 7 2 12.1 GUI........................... 12 1 12.2............................... 12 4 12.3..................................... 12 7 12.4....................................... 12 9 12.5 : FreeCellPanel.java............................
More information新・明解Javaで学ぶアルゴリズムとデータ構造
第 1 章 基本的 1 n 21 1-1 三値 最大値 algorithm List 1-1 a, b, c max // import java.util.scanner; class Max3 { public static void main(string[] args) { Scanner stdin = new Scanner(System.in); List 1-1 System.out.println("");
More information1/8 ページ Java 基礎文法最速マスター Java Javaの文法一覧です 他の言語をある程度知っている人はこれを読めばJavaの基礎をマスターしてJavaを書くことができるようになっています 簡易リファレンスとしても利用できると思いますので これは足りないと思うものがあれば教えてください 1. 基礎 class の作成プログラムはclassに記述します たとえばSampleという名前のclassを作る場合
More information趣味でやる Haskellλ 門 1 ~ 基礎文法編 ~ hiruishi
趣味でやる Haskellλ 門 1 ~ 基礎文法編 ~ hiruishi Haskell の雑な紹介 バグらずに沢山の機能を表現できるよ! というか ( 慣れたら ) ほかの言語で書くより簡潔に書けるよ! プログラミングやったことのない人向け情報 Windows の人はスタートメニューから Windows PowerShell Mac や Linux の人は App メニュー辺りから 端末 だとか
More information1 2 2005 1983 1 ()1984 2 1947 1950 19791996 1
KEO Discussion Paper No.104 19451947 * ** 2006 11 19451947 * ** 1 2 2005 1983 1 ()1984 2 1947 1950 19791996 1 4 A A A A A 3 3 1990 19952003A2003B 4 2 198719941997 1995 1995 3 5 6 1998: 30 40 19701992 7
More informationQ&A集
MapViewer & ver.2 EWEB-3C-N055 PreSerV for Web MapViewer & i 1... 1 1.1... 1 1.2... 2 1.3... 3 1.4... 4 1.5... 5 1.6... 6 1.7... 7 1.8... 8 1.9... 9 1.10...11 1.11...12 1.12...13 1.13...14 1.14...15 1.15...16
More informationPowerPoint Presentation
UML 2004 7 9 10 ... OOP UML 10 Copyright 2004 Akira HIRASAWA all rights reserved. 2 1. 2. 3. 4. UML 5. Copyright 2004 Akira HIRASAWA all rights reserved. 3 1..... Copyright 2004 Akira HIRASAWA all rights
More information