r1.dvi

Similar documents
r9.dvi

r10.dvi

ohp10.dvi

parser.y 3. node.rb 4. CD-ROM

Ruby Ruby ruby Ruby G: Ruby>ruby Ks sample1.rb G: Ruby> irb (interactive Ruby) G: Ruby>irb -Ks irb(main):001:0> print( ) 44=>

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

ohp08.dvi

or a 3-1a (0 b ) : max: a b a > b result a result b ( ) result Python : def max(a, b): if a > b: result = a else: result = b ret

ohp07.dvi

Ruby演習テキスト1

r08.dvi

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse


Microsoft PowerPoint - ruby_instruction.ppt

Windows Cygwin Mac *1 Emacs Ruby ( ) 1 Cygwin Bash Cygwin Windows Cygwin Cygwin Mac 1 Mac 1.2 *2 ls *3 *1 OS Linux *2 *3 Enter ( ) 2

untitled

コンピュータ概論

Appendix A BASIC BASIC Beginner s All-purpose Symbolic Instruction Code FORTRAN COBOL C JAVA PASCAL (NEC N88-BASIC Windows BASIC (1) (2) ( ) BASIC BAS

haskell.gby



Emacs Ruby..

r07.dvi

ohp07.dvi


r03.dvi

listings-ext

ohp03.dvi

つくって学ぶプログラミング言語 RubyによるScheme処理系の実装

Microsoft PowerPoint - Ruby n

untitled

Microsoft PowerPoint - 11RubyIntro-No02.ppt [互換モード]

r2.dvi


( ) ( ) lex LL(1) LL(1)

# let st1 = {name = "Taro Yamada"; id = };; val st1 : student = {name="taro Yamada"; id=123456} { 1 = 1 ;...; n = n } # let string_of_student {n

A


untitled

ohp1.dvi

fp.gby

Ruby 50 Ruby UTF print, \n [Ruby-1] print("hello, Ruby.\n") [Ruby-2] Hello, Ruby. [Ruby-3] print("hello, \"Ruby\".\n") 2 [Ruby-4] seisuu = 10 pr

Smalltalk_

r02.dvi

ohp02.dvi

Excel ではじめる数値解析 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 初版 1 刷発行時のものです.

JavaCard p.1/41

untitled

PowerPoint Presentation

Sequel のすすめ 私が SQL を嫌いな理由 とみたまさひろ RubyHiroba Sequel のすすめ - 私が SQL を嫌いな理由 Powered by Rabbit 2.0.7

離散数理工学 第 2回 数え上げの基礎:漸化式の立て方

Microsoft PowerPoint - 13Kadai.pptx

r3.dvi

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for

2 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

16 NanoPlanner name PlanItem.changeset/2 > validate_required([:name]) name :name Ecto.Changeset validate_required/3 Ecto.Changeset "validate_"

B 5 (2) VBA R / B 5 ( ) / 34

1 Ex Ex. 2 2

ML λ λ 1 λ 1.1 λ λ λ e (λ ) ::= x ( ) λx.e (λ ) e 1 e 2 ( ) ML λx.e Objective Caml fun x -> e x e let 1

離散数理工学 第 2回 数え上げの基礎:漸化式の立て方

() / (front end) (back end) (phase) (pass) 1 2

VDM-SL VDM VDM-SL Toolbox VDM++ Toolbox 1 VDM-SL VDM++ Web bool

(事務局)

2/ 土 :30 11:20 似通った科目名がありますので注意してください. 受験許可されていない科目を解答した場合は無効 整理番号と科目コードは受験許可証とよく照合し正確に記入

Java学習教材

2015-s6-4g-pocket-guidebook_H1-4.indd

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

アルゴリズムとデータ構造1

N88 BASIC 0.3 C: My Documents 0.6: 0.3: (R) (G) : enterreturn : (F) BA- SIC.bas 0.8: (V) 0.9: 0.5:

ALG ppt

JavaScript の使い方


untitled

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

error_g1.eps

10 (1) s 10.2 rails c Rails 7 > item = PlanItem.new => #<PlanItem id nil, name nil,...> > item.name = "" => "" > item.valid? => true valid? true false

Microsoft Word - NonGenList.doc

Copyright c 2006 Zhenjiang Hu, All Right Reserved.


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 clos

プラズマ核融合学会誌4月【84-4】/講座5

D0050.PDF

¥¢¥ë¥´¥ê¥º¥à¥¤¥ó¥È¥í¥À¥¯¥·¥ç¥ó ÎØ¹Ö #1

15 Phoenix HTML 15.1 ModestGreeter RAVT web/router.ex web/router.ex : 12 scope "/", ModestGreeter do 13 pipe_through :browser get "/", TopCont

SCORE−‹Šp‡Ì”è‹ø‡«Ver3

Parametric Polymorphism

untitled

K227 Java 2

Exam : 1z1-809-JPN Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z1-809-JPN Exam's Question and Answers 1 from Ac

Thread

untitled

アルゴリズムとデータ構造1

3 Powered by mod_perl, Apache & MySQL use Item; my $item = Item->new( id => 1, name => ' ', price => 1200,

Python Speed Learning

C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 新装版 1 刷発行時のものです.

test.gby

総合的な経済・エネルギー・環境分析に資する技術情報の整備のための研究

FX ) 2

Transcription:

Ruby 2009.9.7 1 ( ) --- ( ( ) ( ) 1 --- ( ) 1 ( ) (?) IT 7K( )?? ( ) ( )? IT ( ) --- ( ) 1 ( ) --- ( ) (?) 2-3% Top-Level ICT Professional 5% ICT Professional 10% 100% 50% 20% Devl. Experiment Adv. ICT Understandings Basic ICT Understandings User Corp. ICT Person ( )( ) / ( ) ( ) ( ) ) (?) ( ) = 3K) + ( 2 1 2.1 1 ( ) ( ) 1

( ( )?) ( : )( ) I( ) : --- ( (2006) 23( )1020%? Ruby 3.1 ( ) ( ) ( )? Ruby (2007) C Java Ruby? ( )Ruby 2.2 2005: I Java Ruby 2006: ( ) ( ) (90) 2 Ruby Java Java ) 2007: 1 / ( ) Ruby Java (A ) Ruby Ruby 5060( 20+ 30 ) 2008: 2 ) 1( )50% 3 PDF ( 2 / 2 (B ) / ( ) 2

14 1 11 --- Ruby ( )B 8 12 --- ( Java ) 13( GUI) 14( ) B --- Java/ ( ) 1 11 (Ruby ) 3.2 1: / 3.3 2: / if ( ) Ruby 1 def triarea(w, h) def abs1(x) s = (w * h) / 2.0 if x < 0 return s result = -x else result = x 2 ( ) return result irb def abs2(x) if x < 0 return -x irb else return x Java def abs3(x) result = x if x < 0 then result = -x return result ( 1 OK) 3 4 (1 ) 2 / ( ) 2 if while Java Ruby 3

while 2 (f(x)=0 ) dx=w/n 2 N+1 ( ) x ( nil) ( ) def integ1(a, b, n) dx = (b - a) / n; s = 0.0 x = a while x < b y = x**2 s = s + y * dx x = x + dx return s def integ2(a, b, n) dx = (b - a) / n; s = 0.0 n.times do i x = a + i * (b - a) / n; y = x**2 s = s + y * dx return s # f(x) # f(x) (?) ( ) for.times do... ( GCD( step ) ) ( ) fizzbuzz 2 if 3 / fizzbuzz : 1 100 3 fizz5 buzz Ruby ( ) 3.5 4: ( ) / def gcd(x, y) if x == y return x elsif x > y 3.4 3: /f(x)=0 / return gcd(x-y, y) else return gcd(x, y-x) fizzbuzz Pixel = Struct.new (:r, :g, :b) 2 4

initimage( )writeimage( PPM )fillcircle( ) def mypicture initimage fillcircle(150, 30, 60, 255, 100, 70) fillcircle(190, 100, 30, 100, 200, 80) writeimage("t.ppm") 5

6

7

8

3.6 5: / / 3.8 7: / class Dog def initialize(name) @name = name; @speed = 0.0; @count = 3 3 def talk Nputs( my name is + @name) def addspeed(d) @speed = @speed + d puts( speed = + @speed.to_s) def setcount(c) @count = c def bark @count.times do puts( Vow! ) 22 3.7 6: / Gauss-Jordan Jacobi def kazuate a = (rand(10000)+10000).to_s[1..4]; count = 0 while true do Gauss-Seidel printf("your guess? ") s = gets; hit = 0; blow = 0 4.times do i 4.times do j if s[i] == a[j] then Euler if i == j then hit = hit + 1 else blow = blow + 1 Runge-Kutta(2) Runge-Kutta(4) 4 if hit == 4 then puts "you win!"; return count = count + 1? if count > 9 then? (2007 puts "you lose! answer = #{a}."; return puts "hit = #{hit}, blow = #{blow}." ) 9

2 ( RPG ) RubyHash 3.9 8: / (?) class Buffer Cell = Struct.new(:data, :next) def initialize @tail = @cur = Cell.new("EOF", nil) @head = @prev = Cell.new("", @cur) def at return @cur == @tail def top @prev = @head; @cur = @head.next def forward if at then return @prev = @cur; @cur = @cur.next def insert(s) @prev.next = Cell.new(s, @cur); @prev = @prev.next def print puts(" " + @cur.data) top forward insert forward delete head: prev: cur: How How old are head: prev: cur: head: head: head: How prev: How How old old are cur: are prev: are prev: are you? you? you? cur: you? you? tail: EOF tail: EOF tail: EOF tail: EOF cur: tail: EOF 3.10 9: / / A ( ) / $vars = {} class Add def initialize(l, r) @left = l; @right = r def exec() return @left.exec + @right.exec def to_s() return ( + @left.to_s + + + @right.to_s + ) class Mul def initialize(l, r) @left = l; @right = r def exec() return @left.exec * @right.exec def to_s() return ( + @left.to_s + * + @right.to_s + ) class Lit def initialize(v) @left = v def exec() return @left def to_s() return @left.to_s class Var def initialize(v) @left = v def exec() return $vars[@left] def to_s() return @left.to_s def test $vars[ x ] = 5 e = Add.new(Var.new( x ), Lit.new(1)) puts(e); puts(e.exec) e = Add.new(Lit.new(3), 1 Mul.new(Var.new( x ), Lit.new(2))) 1 puts(e); puts(e.exec) e = Mul.new(Add.new(Var.new( x ), Lit.new(3)), Lit.new(2)) puts(e); puts(e.exec) ( ) irb(main):004:0> test! (x + 1) 6 (3 + (x * 2)) 13 ((x + 3) * 2) 16 10

=> nil x = 1 x = 1 ; y = x + 1 ; y = x + 1 class Assign < Node def initialize(l, r) super; @op = = def exec() v = @right.exec; $vars[@left.getleft] = v; return v class Seq < Node def initialize(l, r) super; @op = ; def exec() @left.exec; return @right.exec class Loop < Node def initialize(l, r) super; @op = L def exec() v=0; @left.exec.times do v=@right.exec ; return v def test1 e = Seq.new( Assign.new(Var.new( n ), Lit.new(5)), Seq.new( Assign.new(Var.new( x ), Lit.new(1)), Seq.new( Loop.new( Var.new( n ), Seq.new( Assign.new(Var.new( x ), Mul.new(Var.new( x ), Var.new( n ))), Assign.new(Var.new( n ), Sub.new(Var.new( n ), Lit.new(1))))), Var.new( x )))) puts(e) return e.exec ; y ; y 3.11 10: / ( ) ( ) ( ) ( ) JR 2 / Ruby a b $atm = [{ a => 1}, { b => 0, :final => true}] def accept(s) cur = 0 s.length.times do i k = $atm[cur][s[i..i]]; if k == nil then return false else cur = k return $atm[cur][:final] == true Hash Ruby Ruby (64 ) irb(main):006:0> test1 (((n$)=(5#));(((x$)=(1#));(((n$)l(((x$)= ((x$)*(n$)));((n$)=((n$)-(1#)))));(x$)))) => 120 BNF 11

3.12 11: / ( ( ) 1 1 forward algorithmviterbi 1 4 2 + Ruby Java 2007 ( ) Ruby irb Q. ( Ruby ) Ruby ( ) ( ) Ruby :-) ( Ruby?) ) 5 3 Ruby :? 12

Ruby Ruby, Ruby Ruby Ruby = ( ) html ( Ruby, Ruby Q. (OO ) ( ) Ruby 13

Ruby / /( )n ( ) ( ) 6, J07, http://www.ipsj.or.jp/12kyoiku/, 2009., 2005, http://www.ipsj.or.jp/12kyoiku/, 2005., 2005 2006, http://www.ipsj.or.jp/12kyoiku/, 2006.,,,, 2008., Ruby,, 2008. Tim Bell,,,, 2007. 14