Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (not_ item)
- (
- cond ((EQ? item #f) #t)
- ( #t #f)
- )
- )
- (define (and_ item1 item2)
- (cond ((EQ? item1 #f) #f)
- ((EQ? item2 #f) #f)
- (#t #t)
- )
- )
- (define (or_ item1 item2)
- ( not_ (and_ (not_ item1) (not_ item2) ) )
- )
- (define (count_ lst len)
- (cond ((EQV? lst '() ) len )
- ((not_ (PAIR? lst)) len )
- ( (= 1 1) (
- count_ (cdr lst ) (+ len 1)
- ))))
- (define (get_by_index array index)
- (cond ((= index 1)
- (cond (( and_ (PAIR? (car array)) (not_ (LIST? (car array))) )
- array
- )
- ((LIST? array) (car array) )
- ((= 1 1) array)
- )
- )
- ((= 1 1) (get_by_index (cdr array) ( - index 1) ) )
- )
- )
- (define (calculete my_list)
- (cond ((and_ (not_ (LIST? my_list)) (not_ (PAIR? my_list))) "atom" )
- (( EQ? my_list '() ) '() )
- (( = 1 1) (get_by_index my_list (count_ my_list 0)) )
- )
- )
- (calculete "ff")
- (calculete '())
- (calculete '(4 53 5345435 555))
- (calculete '(3 5 53 6 7 4 3 . 5))
- (calculete '(3 5 53 6 7 (4 3 5 6 . 6) ))
- (calculete '( 3 . 5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement