<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 9.00.8112.16455"></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=458435213-30112012><FONT color=#0000ff
size=2 face=Arial>What you are asking for seems like alpha congruence, but less
restrictive. How much less restrictive? That depends on you definition of "the
same pattern". In length you have "(car l)" and in length you have "1". Do they
have the same structure? That, of course depends on the definition of car (it
may have been redefined). If you suppose that commonly used functions are not
redefined, you might argue that both"car l" and "1" are atomic-like things.
So you need to define "atomic-like".</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=458435213-30112012><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=458435213-30112012><FONT color=#0000ff
size=2 face=Arial>Consider also:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=458435213-30112012><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=458435213-30112012><FONT color=#0000ff
size=2 face=Arial>(define (flatten x)<BR> (cond<BR> ((null? x)
'())<BR> ((pair? x) (append (flatten-helper (car x)) (flatten (cdr
x))))<BR> (else (list x))))</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><SPAN class=458435213-30112012><FONT color=#0000ff
size=2 face=Arial>(define flatten-helper flatten)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=458435213-30112012><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=458435213-30112012><FONT color=#0000ff
size=2 face=Arial>I suppose that in your opinion, flatten does not have the same
structure as sum and length. You need to know that (flatten-helper (car x)) is
not "atomic-like".</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=458435213-30112012><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=458435213-30112012><FONT color=#0000ff
size=2 face=Arial>Just some thoughts, Jos</FONT></SPAN></DIV><BR>
<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>From:</B> users-bounces@racket-lang.org
[mailto:users-bounces@racket-lang.org] <B>On Behalf Of </B>Mohammad
Mustaqeem<BR><B>Sent:</B> viernes, 30 de noviembre de 2012 9:24<BR><B>To:</B>
users@racket-lang.org<BR><B>Subject:</B> [racket] Matching patterns of two
function<BR></FONT><BR></DIV>
<DIV></DIV>I have a problem in matching the patterns of two functions.
<DIV>I want to match two function whether they are following the same pattern or
not?</DIV>
<DIV>e.g.</DIV>
<DIV>The "sum" function that computes the sum of all the elements of the list
and "length" function that computes the length of the list.</DIV>
<DIV>Here, we see that both the functions have same pattern.</DIV>
<DIV><BR></DIV>
<DIV>
<DIV>(define (sum l)</DIV>
<DIV> (cond[(empty? l)0]</DIV>
<DIV> [else (+ (car l)(sum (cdr l)))]))</DIV>
<DIV><BR></DIV>
<DIV>(define (length l)</DIV>
<DIV> (cond[(empty? l)0]</DIV>
<DIV> [else (+ 1(length (cdr l)))]))</DIV></DIV>
<DIV><BR></DIV>
<DIV>How can we determine that both has same pattern or not?</DIV>
<DIV>I want to write a function that takes these functions as input and tells
whether they have same pattern or not.</DIV></BODY></HTML>