Your SlideShare is downloading. ×
Kof2008 Itll
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Kof2008 Itll

1,095

Published on

“Introduction to Lazy lists” …

“Introduction to Lazy lists”
How to use and construct lazy lists on Programming Langage Ruby.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,095
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Introduction to Lazy Lists 2008 UJIHISA, Tatsuhiro
  • 2. UJIHISA Tatsuhiro • Osaka University • Ruby, Vim, Haskell and Math • http://ujihisa.nowa.jp • http://twitter.com/ujm • To the US!
  • 3. Targets • • Array, Enumerable, IO (File) Haskell
  • 4. Lazy lists
  • 5. • Ruby Haskell (Lazy list) Live coding Vim
  • 6. Lazy Lists • Lazy lists (or streams) • List (= Array in Ruby) • Only needed parts are calculated. • Haskell supports lazy lists by default. • Ruby can support it.
  • 7. List (=Array) in Ruby • Array class • [0, 1, 2, 3], Array.new(4) {|i| i } • a #=> [0, 1, 2, 3] a.map {|i| i * 2 } #=> [0, 2, 4, 6]
  • 8. List • Data structure • Insert, Delete, Access sequentially
  • 9. c.f. Array • Data structure • Insert, Delete, Access randomly, Size
  • 10. (List again) • Data structure • Insert, Delete, Access sequentially
  • 11. Lazy List • Data structure • Insert, Delete, Access sequentially
  • 12. Types of lazy lists • Boundless length lists ( ) • Undefined length lists ( ) • Defined length lists ( )
  • 13. How to construct lazy lists?
  • 14. Notations • array = 1000+ length array heavy = lambda { heavy procedure } • array.take(2).map(&heavy) • array.map(&heavy).take(2)
  • 15. Common case • truncation (break) • filtering (if, unless; select, reject) • mapping (=, map) • processing (???, each) folding (<<, inject)

×