Advertisement
PonaFly

Untitled

Dec 16th, 2018
889
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.96 KB | None | 0 0
  1. #lang scheme
  2. (define (find lst)
  3.  
  4.  (define (to_number lst i n )
  5.    (if (empty? lst) n
  6.        (to_number (cdr lst) (+ i 1) (+ n (* (car lst) (expt 10 i))))))
  7.  
  8.  (define (check number temp_lst)
  9.     (if (or (= number 0) (empty? lst)) (to_number (reverse temp_lst) 0 0)
  10.         (if (member (remainder number 10) temp_lst) (find (cdr lst))
  11.             (check (quotient number 10) (cons (remainder number 10) temp_lst)))))
  12.  
  13.   (if (empty? lst) #f
  14.       (check (car lst) '() )))
  15.  
  16.  
  17. (define (count_words x y)
  18.   (define str (string->list x))
  19.   (define spls (string->list y))
  20.   (define (proverka str words flag)
  21.   (if (empty? str) words
  22.     (if (and (= 0 flag) (member (car str) spls))(proverka (cdr str) words  flag)
  23.        (if (and (= flag 0) (not(member (car str) spls)))(proverka (cdr str) (+ 1 words) 1)
  24.            (if (and (= flag 1) (member (car str) spls)) (proverka (cdr str)  words 0)
  25.                 (proverka (cdr str) words 1))))))
  26.   (proverka str 0 0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement