Advertisement
Guest User

Zajecia2-scheme

a guest
Jan 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 1.02 KB | None | 0 0
  1. (define (allZeros list)
  2.   (if (null? list) 1
  3.       (if (cdr(list)))))
  4.  
  5. (define (headTailConf head tail dist)
  6.   (if (null? tail) '()
  7.       (cons (Conflict head (car tail) dist)
  8.             (headTailConf head (cdr tail) (+ dist 1)))))
  9.  
  10. (define (numberOfConf stan)
  11.   (if (null? stan) '()
  12.       (let ((htc (headTailConf (car stan) (cdr stan))
  13.                  (cons (if (allZeros htc) 0 1)
  14.                        (alternative htc (numberOfConf (cdr stan)))))))))
  15.  
  16. (define (minConf state n)
  17.   (if (equal? n 0) 'failure
  18.       (let ((confList (numberOfConf state)))
  19.         (if (allZeros confList) state
  20.             (minConf (change (state confList) (- n 1)))))))
  21.  
  22.  
  23. ; odwracanie list z dobra zlozonoscia
  24.  
  25. ; mapowanie
  26.  
  27. ; filtrowanie - dostaje funckje ktora mowi czy dany element zostawic czy nie, jesli zwraca prawde to zostawiam jesli nie to wyrzuć np. (flitruj '(1 2 3 4) parzyste) -> '(1 3)
  28.  
  29. ; w/w dokonczyc:
  30. ;  minConf      v
  31. ;  numberOfConf v
  32. ;  headTailConf v
  33. ;  allZeros     x?
  34. ;  minConf      x?
  35. ;  Conflict     x?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement