Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (allZeros list)
- (if (null? list) 1
- (if (cdr(list)))))
- (define (headTailConf head tail dist)
- (if (null? tail) '()
- (cons (Conflict head (car tail) dist)
- (headTailConf head (cdr tail) (+ dist 1)))))
- (define (numberOfConf stan)
- (if (null? stan) '()
- (let ((htc (headTailConf (car stan) (cdr stan))
- (cons (if (allZeros htc) 0 1)
- (alternative htc (numberOfConf (cdr stan)))))))))
- (define (minConf state n)
- (if (equal? n 0) 'failure
- (let ((confList (numberOfConf state)))
- (if (allZeros confList) state
- (minConf (change (state confList) (- n 1)))))))
- ; odwracanie list z dobra zlozonoscia
- ; mapowanie
- ; 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)
- ; w/w dokonczyc:
- ; minConf v
- ; numberOfConf v
- ; headTailConf v
- ; allZeros x?
- ; minConf x?
- ; Conflict x?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement