[racket] Matching patterns of two function

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Nov 30 09:40:48 EST 2012

Do you mean pattern as in 
 -- substitution 
 -- unification 

In this particular case, you could synthesize the pattern 

> (define (FFF l)
>   (cond[(empty? l)0]
>        [else (+ (XXX l) (FFF (cdr l)))]))

and then claim that 
 -- sum = FFF with XXX = first 
 -- length = FFF with XXX = (K 1)

On Nov 30, 2012, at 3:23 AM, Mohammad Mustaqeem wrote:

> I have a problem in matching the patterns of two functions.
> I want to match two function whether they are following the same pattern or not?
> e.g.
> The "sum" function that computes the sum of all the elements of the list and "length" function that computes the length of the list.
> Here, we see that both the functions have same pattern.
> (define (sum l)
>   (cond[(empty? l)0]
>        [else (+ (car l)(sum (cdr l)))]))
> (define (length l)
>   (cond[(empty? l)0]
>        [else (+ 1(length (cdr l)))]))
> How can we determine that both has same pattern or not?
> I want to write a function that takes these functions as input and tells whether they have same pattern or not.
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4373 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20121130/334298a6/attachment.p7s>

Posted on the users mailing list.