Advertisement
chemoelectric

Untitled

Jan 29th, 2013
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. FUN WITH ITERATORS
  2.  
  3. A snippet from my user-init.scm:
  4.  
  5. (define next! (pyiterable->!procedure (make-pylist (py-none) (py-true) (py-false))))
  6. (write (pyiterable? (pyiterable->pyiterator (make-pylist (py-none) (py-true) (py-false))))) (newline)
  7. (write (pyiterable? next!)) (newline)
  8. (write (pyiterable? (pyeval-in-main "(i for i in range (10))"))) (newline)
  9. (write (pygenerator? (pyiterable->pyiterator (make-pylist (py-none) (py-true) (py-false))))) (newline)
  10. (write (pygenerator? next!)) (newline)
  11. (write (pygenerator? (pyeval-in-main "(i for i in range (10))"))) (newline)
  12. (write (next!)) (newline)
  13. (write (next!)) (newline)
  14. (write (next!)) (newline)
  15. (write (next!)) (newline)
  16. (write (next!)) (newline)
  17. (define next2! (pyiterable->!procedure (pyeval-in-main "(i for i in range (10))")))
  18. (write (next2!)) (newline)
  19. (write (next2!)) (newline)
  20. (write (next2!)) (newline)
  21. (write (next2!)) (newline)
  22. (write (next2!)) (newline)
  23. (write (next2!)) (newline)
  24. (write (next2!)) (newline)
  25. (write (next2!)) (newline)
  26. (write (next2!)) (newline)
  27. (write (next2!)) (newline)
  28. (write (next2!)) (newline)
  29. (write (next2!)) (newline)
  30. (write (next2!)) (newline)
  31. (write (next2!)) (newline)
  32. (write (next2!)) (newline)
  33.  
  34. And the output:
  35.  
  36. #t
  37. #f
  38. #t
  39. #f
  40. #f
  41. #t
  42. #<pyobject repr:None 0x7f30b99dfea0>
  43. #<pyobject repr:True 0x7f30b99cba60>
  44. #<pyobject repr:False 0x7f30b99cba80>
  45. #f
  46. #f
  47. #<pyobject repr:0 0x39a4c60>
  48. #<pyobject repr:1 0x39a4c48>
  49. #<pyobject repr:2 0x39a4c30>
  50. #<pyobject repr:3 0x39a4c18>
  51. #<pyobject repr:4 0x39a4c00>
  52. #<pyobject repr:5 0x39a4be8>
  53. #<pyobject repr:6 0x39a4bd0>
  54. #<pyobject repr:7 0x39a4bb8>
  55. #<pyobject repr:8 0x39a4ba0>
  56. #<pyobject repr:9 0x39a4b88>
  57. #f
  58. #f
  59. #f
  60. #f
  61. #f
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement