Advertisement
PonaFly

addition graph

Apr 27th, 2016
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. (define (addition graf)
  2. (define helplst (build-list (car graf) values))
  3.  
  4. (define (myfoldl lst i result)
  5. (if (empty? lst) result
  6. (myfoldl (cdr lst) (+ i 1) (append (find (cdar lst) '() i helplst) result))))
  7.  
  8. (myfoldl (cdr graf) 0 '()))
  9.  
  10.  
  11. (define (find lst result i helplst)
  12. (if (or(empty? helplst) (>=(car helplst) i)) result
  13.  
  14. (if (not(member (car helplst) lst))
  15. (find lst (cons (cons i (car helplst)) result) i (cdr helplst))
  16. (find lst result i (cdr helplst)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement