Upcoming SlideShare
×

# Stateモナドの解説 中編

1,264 views
1,188 views

Published on

Published in: Technology
3 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
1,264
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
22
0
Likes
3
Embeds 0
No embeds

No notes for slide

### Stateモナドの解説 中編

1. 1. State 2009 5 31 id:hiratara 2009 5 31
2. 2. • = + • State 2009 5 31
3. 3. (1) State 2009 5 31
4. 4. State → State Int String State Int String State Int Int State Int Int State Int MyType State Int MyType State Int Maybe Bool State Int (Maybe Bool) 2009 5 31
5. 5. State Int String State Int String quot;ABCquot; quot;12345quot; quot;hogequot; State Int Int State Int Int 236 8974 2009 5 31
6. 6. State State Int String State Int String quot;ABCquot; ??? quot;12345quot; ??? quot;hogequot; State Int ??? Int State Int Int 236 ??? 8974 ??? 2009 5 31
7. 7. A). counter B). counter 1 2009 5 31
8. 8. A) B) State A). counter B). counter 1 2009 5 31
9. 9. A). 1 quot;aquot; 2 quot;aaquot; 3 quot;aaaquot; ... 2009 5 31
10. 10. B). 1 (quot;aquot;, 2) 2 (quot;aaquot;, 3) 3 (quot;aaaquot;, 4) ... 2009 5 31
11. 11. State Int String 1 (quot;bquot;, 2) chars ‘b’ = 2 (quot;bbquot;, 3) 3 (quot;bbbquot;, 4) ... 1 (quot;*quot;, 2) chars ‘*’ = 2 (quot;**quot;, 3) 3 (quot;***quot;, 4) ... 1 (quot; quot;, 2) chars ‘ ’ = 2 (quot; quot;, 3) 3 (quot; quot;, 4) ... 2009 5 31
12. 12. State State Int String Int -> (String, Int) 1 (quot;*quot;, 2) 2 (quot;**quot;, 3) 3 (quot;***quot;, 4) ... 2009 5 31
13. 13. State s0 v(s0) (v(s0), s(s0)) s(s0) : Int -> (String, Int) 1 (quot;*quot;, 2) 2 (quot;**quot;, 3) (‘*’ s0 , s0 + 1) 3 (quot;***quot;, 4) ... 2009 5 31
14. 14. (2) return 2009 5 31
15. 15. return State State Int String return State Int String quot;ABCquot; ??? quot;12345quot; ??? State Int ??? Int return State Int Int 236 ??? ??? 2009 5 31
16. 16. State Int String return State Int String quot;ABCquot; ??? quot;12345quot; ??? State Int ??? Int return State Int Int 236 ??? ??? 2009 5 31
17. 17. State State Int String return State Int String quot;ABCquot; (“ABC”, s0) quot;12345quot; (“12345, s0) State Int ??? Int return State Int Int 236 (236, s0) ??? 2009 5 31
18. 18. State Int String return State Int String quot;ABCquot; (“ABC”, s0) quot;12345quot; (“12345, s0) State Int (v(s0), s(s0)) Int return State Int Int 236 (236, s0) (v’(s0), s’(s0)) 2009 5 31
19. 19. • State s0 s0 v(s0) s0 s(s0) 2 • a State (a, s0) ( return ) 2009 5 31
20. 20. • State • State State • State ( >>= ) 2009 5 31