lundi 18 février 2019

Scheme function that takes two lists and computes how many times the pattern within the first list appears in the second list

(define (pattern lis1 lis2)
    (cond ((null? lis1) 0)
        (( = (car lis1) lis2) ( + 1 (pattern (cdr lis1) lis2)))
        (else (pattern (cdr lis1) lis2))))

This is what I have so far but when I run this I receive the error "=: expects a number as 2nd argument, given 'a" when I enter (pattern '(a a) '(a a a a a a a))

Aucun commentaire:

Enregistrer un commentaire