Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FUN WITH ITERATORS
- A snippet from my user-init.scm:
- (define next! (pyiterable->!procedure (make-pylist (py-none) (py-true) (py-false))))
- (write (pyiterable? (pyiterable->pyiterator (make-pylist (py-none) (py-true) (py-false))))) (newline)
- (write (pyiterable? next!)) (newline)
- (write (pyiterable? (pyeval-in-main "(i for i in range (10))"))) (newline)
- (write (pygenerator? (pyiterable->pyiterator (make-pylist (py-none) (py-true) (py-false))))) (newline)
- (write (pygenerator? next!)) (newline)
- (write (pygenerator? (pyeval-in-main "(i for i in range (10))"))) (newline)
- (write (next!)) (newline)
- (write (next!)) (newline)
- (write (next!)) (newline)
- (write (next!)) (newline)
- (write (next!)) (newline)
- (define next2! (pyiterable->!procedure (pyeval-in-main "(i for i in range (10))")))
- (write (next2!)) (newline)
- (write (next2!)) (newline)
- (write (next2!)) (newline)
- (write (next2!)) (newline)
- (write (next2!)) (newline)
- (write (next2!)) (newline)
- (write (next2!)) (newline)
- (write (next2!)) (newline)
- (write (next2!)) (newline)
- (write (next2!)) (newline)
- (write (next2!)) (newline)
- (write (next2!)) (newline)
- (write (next2!)) (newline)
- (write (next2!)) (newline)
- (write (next2!)) (newline)
- And the output:
- #t
- #f
- #t
- #f
- #f
- #t
- #<pyobject repr:None 0x7f30b99dfea0>
- #<pyobject repr:True 0x7f30b99cba60>
- #<pyobject repr:False 0x7f30b99cba80>
- #f
- #f
- #<pyobject repr:0 0x39a4c60>
- #<pyobject repr:1 0x39a4c48>
- #<pyobject repr:2 0x39a4c30>
- #<pyobject repr:3 0x39a4c18>
- #<pyobject repr:4 0x39a4c00>
- #<pyobject repr:5 0x39a4be8>
- #<pyobject repr:6 0x39a4bd0>
- #<pyobject repr:7 0x39a4bb8>
- #<pyobject repr:8 0x39a4ba0>
- #<pyobject repr:9 0x39a4b88>
- #f
- #f
- #f
- #f
- #f
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement