Advertisement
Jobjob

Programmation déclarative - Q4B - 08/2012

Jan 4th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.49 KB | None | 0 0
  1. (define (offset s t)
  2.   (letrec
  3.       ((elements-to-reach (lambda (e stream i)
  4.                             (if (= e (head stream))
  5.                                 (list i stream)
  6.                                 (elements-to-reach e (tail stream) (+ i 1))
  7.                                 )
  8.                             )
  9.                           )
  10.        )
  11.     (let
  12.         ((res (elements-to-reach (head t) s 0)))
  13.       (cons-stream (car res) (offset (cadr res) (tail t)))
  14.       )
  15.     )
  16.   )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement