Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #lang scheme
- (define (find lst)
- (define (to_number lst i n )
- (if (empty? lst) n
- (to_number (cdr lst) (+ i 1) (+ n (* (car lst) (expt 10 i))))))
- (define (check number temp_lst)
- (if (or (= number 0) (empty? lst)) (to_number (reverse temp_lst) 0 0)
- (if (member (remainder number 10) temp_lst) (find (cdr lst))
- (check (quotient number 10) (cons (remainder number 10) temp_lst)))))
- (if (empty? lst) #f
- (check (car lst) '() )))
- (define (count_words x y)
- (define str (string->list x))
- (define spls (string->list y))
- (define (proverka str words flag)
- (if (empty? str) words
- (if (and (= 0 flag) (member (car str) spls))(proverka (cdr str) words flag)
- (if (and (= flag 0) (not(member (car str) spls)))(proverka (cdr str) (+ 1 words) 1)
- (if (and (= flag 1) (member (car str) spls)) (proverka (cdr str) words 0)
- (proverka (cdr str) words 1))))))
- (proverka str 0 0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement