Advertisement
Void-voiD

Untitled

Dec 9th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. (define (make-source s . end)
  2. (if (string? s)
  3. (if (null? end)
  4. (let ((static (reverse (cons #f (reverse (string->list s))))))
  5. (lambda (x)
  6. (if (= (length static) 1)
  7. (car static)
  8. (if (equal? x 'peek)
  9. (car static)
  10. (if (equal? x 'next)
  11. (begin
  12. (let ((cur (car static)))
  13. (begin
  14. (set! static (cdr static))
  15. cur)))
  16. static)))))
  17. (let ((static (reverse (cons (car end) (reverse (string->list s))))))
  18. (lambda (x)
  19. (if (= (length static) 1)
  20. (car static)
  21. (if (equal? x 'peek)
  22. (car static)
  23. (if (equal? x 'next)
  24. (begin
  25. (let ((cur (car static)))
  26. (begin
  27. (set! static (cdr static))
  28. cur)))
  29. static))))))
  30. (if (vector? s)
  31. (if (null? end)
  32. (let ((static (reverse (cons #f (reverse (vector->list s))))))
  33. (lambda (x)
  34. (if (= (length static) 1)
  35. (car static)
  36. (if (equal? x 'peek)
  37. (car static)
  38. (if (equal? x 'next)
  39. (begin
  40. (let ((cur (car static)))
  41. (begin
  42. (set! static (cdr static))
  43. cur)))
  44. static)))))
  45. (let ((static (reverse (cons (car end) (reverse (vector->list s))))))
  46. (lambda (x)
  47. (if (= (length static) 1)
  48. (car static)
  49. (if (equal? x 'peek)
  50. (car static)
  51. (if (equal? x 'next)
  52. (begin
  53. (let ((cur (car static)))
  54. (begin
  55. (set! static (cdr static))
  56. cur)))
  57. static))))))
  58. (if (null? end)
  59. (let ((static (reverse (cons #f (reverse s)))))
  60. (lambda (x)
  61. (if (= (length static) 1)
  62. (car static)
  63. (if (equal? x 'peek)
  64. (car static)
  65. (if (equal? x 'next)
  66. (begin
  67. (let ((cur (car static)))
  68. (begin
  69. (set! static (cdr static))
  70. cur)))
  71. static)))))
  72. (let ((static (reverse (cons (car end) (reverse s)))))
  73. (lambda (x)
  74. (if (= (length static) 1)
  75. (car static)
  76. (if (equal? x 'peek)
  77. (car static)
  78. (if (equal? x 'next)
  79. (begin
  80. (let ((cur (car static)))
  81. (begin
  82. (set! static (cdr static))
  83. cur)))
  84. static)))))))))
  85.  
  86. (define (peek x)
  87. (x 'peek))
  88.  
  89. (define (next x)
  90. (x 'next))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement