f

#### What do the authors in The Little Schemer mean by the "function's structure" and "argument's structure"?

```Hi all,

I finished reading The Little Schemer a few days ago and one of the
answers was not clear to me.

It's on page 40, 3rd from the top. It's about simplifying the rember
function (which removes the first occurrence of an element from a
list).

The question asks "So why don't we simplify right away?" and the
answer is "Because then a function's structure does not coincide
with its argument's structure."

Any ideas what "a function's structure" and "argument's structure"
are? And how do they coincide or not coincide?

Here is the original function:

(define rember
(lambda (a lat)
(cond
((null? lat) '())
((eq? (car lat) a) (cdr lat))
(else (cond
((eq? (car lat) a) (cdr lat))
(else (cons (car lat)
(rember a (cdr lat)))))))))

And here is the simplified version:

(define rember
(lambda (a lat)
(cond
((null? lat) '())
((eq? (car lat) a) (cdr lat))
(else (cons (car lat)
(rember a (cdr lat)))))))

Thanks!

Peteris Krumins
```
 0
2/14/2010 4:40:54 AM
comp.lang.scheme 4781 articles. 0 followers.

1 Replies
972 Views

Similar Articles

[PageSpeed] 3

```On Feb 13, 11:40 pm, Peteris Krumins <peteris.krum...@gmail.com>
wrote:
> Any ideas what "a function's structure" and "argument's structure"
> are? And how do they coincide or not coincide?
>
> Here is the original function:
>
> (define rember
>   (lambda (a lat)
>     (cond
>       ((null? lat) '())
>       ((eq? (car lat) a) (cdr lat))
>       (else (cond
>               ((eq? (car lat) a) (cdr lat))
>               (else (cons (car lat)
>                           (rember a (cdr lat)))))))))

This is not the original function: you've inserted the second clause
of the cond expression. A list is either null, or a cons of something
onto a list. That is the structure of the argument, and so should be
the basis for the structure of the function. Since the argument can
take on one of exactly two forms, the function should naturally handle
exactly those two forms. The structure of the argument informs the
nature of the recursion in the function definition.

Once you have accounted for all possible forms your argument(s) can
take on, then you can think about transformations that preserve the

Anthony
```
 0
2/15/2010 3:38:13 PM

Similar Artilces:

There's "Unix", and then there's "UNIX(r)"
From TOW[1]: The Open Group, an industry standards consortium, now owns the UNIX trademark and allows its use for certified operating systems compliant with its standard, the Single UNIX Specification. Other operating systems that emulate Unix to some extent may be called Unix-like, although the Open Group disapproves of this term.[4] The term Unix is also often used informally to denote any operating system that closely resembles the trademarked system. The most common version of Unix (bearing certification) is Apple's OS X, while Linux is the most popular non-certified workalike. So, to summarize: "Unix" is a class of operating systems that is "UNIX-like", which includes Linux. "UNIX(r)" is a trademark of the Open group, who -- somewhat snootily -- have an issue with the term "UNIX-like". (They can take a flying fsck.) "Cult of Unix" spells "Unix" as "Unix", because otherwise, what would it have to do with Linux? This PSA brought to you by the letter "U" and the number "2". -v Unix minions, unite! On 2/9/14, 1:15 PM, in article ld8nlg\$bu7\$1@dont-email.me, "vallor" <vallor@cultnix.org> wrote: > From TOW[1]: > > The Open Group, an industry standards consortium, now owns the UNIX > trademark and allows its use for certified operating systems > compliant with its standard, the Single UN...

Why doesn't Python's "robotparser" like Wikipedia's "robots.txt" file?
For some reason, Python's parser for "robots.txt" files doesn't like Wikipedia's "robots.txt" file: >>> import robotparser >>> url = 'http://wikipedia.org/robots.txt' >>> chk = robotparser.RobotFileParser() >>> chk.set_url(url) >>> chk.read() >>> testurl = 'http://wikipedia.org' >>> chk.can_fetch('Mozilla', testurl) False >>> The Wikipedia robots.txt file passes robots.txt validation, and it doesn't disallow unknown browsers. But the Python pars...

I am trying to retrieve the user name (network login) of clients running a local Access DB. We use Access 2000 / 2003 and Windows XP SP 2. I have used 2 different ways to access this information from within Access: OPTION 1: Use Environ("username") OPTION 2: Use Dev Ashish's code (http://www.mvps.org/access/api/ api0008.htm) Both options seem to behave exactly the same for me. But this is my problem: On some clients I correctly retrieve the network login name and on some other clients I retrieve '#Name?'. On ALL clients though, if you you open command prompt and execute 'echo %username%' you get the correct answer - even on the clients that I get the '#Name?' answer. I suspect I have some missing reference somewhere in the clients that can't display the username correctly but I don't know how to go about it. Any assistance is appreciated. ...

Dijkstra's "Enumeration" = "Metrics" his "Abstraction" = "Quality"
"Enumerative reasoning is only an adequate mental tool under the severe boundary condition that we only use it very moderately. We should appreciate abstraction as our main mental technique to reduce the demands made upon enumerative reasoning." ~ EW Dijkstra This is critically decisive because Dijkstra is saying that in most *software engineering" contexts, most of the time, abstraction is key relative to "metrics", the numerical, the quantitative. It is a TOWWWEEERRRING, grand slam "home run". It is of Doug William's 3-4 perfectly pitched Super Bowl touchdowns. It is growth in insight after Dijkstra one of THE very best ran into major impasses attempting to drive development with metrics. His insight is that ABSTRACTION should "lead" the way. While there is the dialectic: metrics<=>abstraction The predominant factor to engage and lead software engineering by is "abstraction". So notation wise better: metrics<=>abstraction* And to denote analyzing or summarizing the dialectic applied in whatever context, from point 'a' to 'b': a,b{ metrics<=>abstraction* Discrete points: a,b; l,q{ metrics<=>abstraction* Have at your own meaningful fun! Elliott -- Global Plans + IID = part of an optimal approach On Wed, 4 Feb 2004 23:36:17 -0500, "Universe" <universe@tAkEcovadOuT.net> wrote: >"Enumerative reasoning is only an adequate mental tool und...

Lisp's "some" and "every" functions
Dear Perl community, Recently I've been learning some Lisp on my own, and I've come across two Lisp functions that I wish Perl had: "some" and "every". They work somewhat like "grep" and "map" in that they operate on a list given a function, but they return only a boolean value. For example, in Lisp, to find out if at least one number in a list is an odd number, you could write: (some #'oddp '(1 2 3 4 5)) or even: (some (lambda (x) (= 1 (mod x 2))) '(1 2 3 4 5)) In Perl, you COULD write: if ( gre...

[why are trailing '\n's missing in "\$x"]: x="\$(printf "hi\n\n")"; printf "\$x"
Ex ~ \$ printf "hi\n\n"|cat -A hi\$ \$ ~ \$ x="\$(printf "hi\n\n")" ~ \$ printf "\$x"|cat -A hi~ \$ Why are the trailing '\n's not in "\$x"? Is there any way to stop this, w/o using a tempfile? -- thanks! On 12/29/2013 11:34 PM, Name withheld by request wrote: > x="\$(printf "hi\n\n")" x="\$(printf "%s" "hi\n\n")" Best regards, Cyrus In article <bibnk6Ftcm6U1@mid.individual.net>, Cyrus Kriticos <cyrus.kriticos@googlemail.com> wrote: >On 12/29/2013 11:34 PM, Name withheld by request wrote: >> x="\$(printf "hi\n\n")" > >x="\$(printf "%s" "hi\n\n")" > >Best regards, >Cyrus Which is, at best, a pedantic nitpick, having nothing to do with OP's problem. In fact, ITYM: x="\$(printf "%s\n\n" "hi")" (which still doesn't solve OP's problem, but at least demonstrates better pedantry) -- Watching ConservaLoons playing with statistics and facts is like watching a newborn play with a computer. Endlessly amusing, but totally unproductive. On 12/30/2013 12:00 AM, Kenny McCormack wrote: > In article <bibnk6Ftcm6U1@mid.individual.net>, > Cyrus Kriticos <cyrus.kriticos@googlemail.com> wrote: >> On 12/29/2013 11:34 PM, Name withheld by request wrote: >>> x="...

What's the meaning of ".."? And A "Bug" of Maple 10?
Hi all, When I calculated a limit, I found something like "..". What's the meaning of that? My worksheet is as follow. >restart; >assume(w,real); > assume(n>0); > f:=exp(-I*w*sqrt(n))/(1-I*w/sqrt(n))^n; 1/2 exp(-I w~ n~ ) f := ---------------- / w~ I \n~ |1 - -----| | 1/2| \ n~ / > limit(f, n=infinity); ...

Hi, I wanted to remove the first zero from 0416 E. BAILEY 101, but not from 0 S 356 MADISON. I ran the following code and I have problem with the line: ------------------------ street_n=addr1_1|" "||addr2||" "||addr3||" "||addr4||" "||addr5; ---------------------- My desired output is something like this under one single variable "street_n": 416 E. BAILEY 101 0S356 MADISON Hope to get some help from out there. Thanks, Duckhye. data a; input street \$1-19; cards; 0416 E. BAILEY 101 0 S 356 MADISON ; run; data b;set a; addr1=put(left(scan...

putty terminal, where's the "do" "select" "remove" key?
I want to start using putty, but I can't figure out where all the lk201 keys are. Any help??? On 2013-05-14 16:45:02 +0000, jon@jonathanleslie.com said: > I want to start using putty, but I can't figure out where all the lk201 > keys are. Any help??? Start reading here <http://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/function-keys.html> and here <http://www.chiark.greenend.org.uk/~sgtatham/putty/faq.html#faq-keyboard> and particularly here <http://www.parsec.com/general/technical.php?i=2513&r=7K5K3H&d=OpenVMS>. qv: NumLock is PF1 in VT400 mode, and the editing keypad is listed there, too. In general, dependencies on function keys are full of fail in this era. It hurts, yes, but the faster you get rid of your dependences on this morass, the better off you'll be. -- Pure Personal Opinion | HoffmanLabs LLC On Tuesday, May 14, 2013 12:45:02 PM UTC-4, j...@jonathanleslie.com wrote: > I want to start using putty, but I can't figure out where all the lk201 keys are. Any help??? Forget about PuTTY. Tera Term is a much better free VT emulation. http://logmett.com/index.php?/products/teraterm.html Neil Rieck Kitchener / Waterloo / Cambridge, Ontario, Canada. http://www3.sympatico.ca/n.rieck/OpenVMS.html In article <0327fda4-76e6-4197-ae6d-c8ffa7e172a1@googlegroups.com>, jon@jonathanleslie.com writes: > I want to start using putty, but I can'...

In Metapost, What's the difference between "=" and ":="?
Hi, I don't see explanation about the difference between "=" and ":=" in Metapost? Do you know what's the difference? Thanks, Peng Peng Yu <pengyu.ut@gmail.com> writes: > Hi, > > I don't see explanation about the difference between "=" and ":=" in > Metapost? > > Do you know what's the difference? := is an assignment: "go put that value in there right now", = is just another constraint that will be solved: "go find a solution that satisfies this constraint." Of course, with "a=3cm", there's not many values that will work for a. Consider a = 3cm; a := 4cm; If the second assignment were just an equation, mpost would complain that 3cm does not equal 4cm, because you're saying you want a to be 3cm and 4cm at the same time. HTH Ulrich -- Getting lost in the \footnotes and \temporals? Talcum makes LaTeX more fun. Now with whole new bugs ;), and, of course, still with special Beamer support. http://talcum.sarovar.org/ (Current release: 0.4.3) Peng Yu <pengyu.ut@gmail.com> writes: > I don't see explanation about the difference between "=" and ":=" in > Metapost? > > Do you know what's the difference? The METAFONT-book (among others) explains this. := is just the ordinary assignment of most programming languages: it unbinds the variable at the left side, calculates the value at the right side and then ass...

sed 's/"""//' foobar | more
Hello I am a total newbie to sed, and I am using sed on DOS, I guess from some kind of Unix-compatible toolset that is installed: >C:\tmp>which sed /usr/bin/sed Please tell me why is this (foobar is an empty file): C:\tmp>sed 's/"""//' foobar | more sed: can't read |: No such file or directory sed: can't read more: No such file or directory Normally, DOS | is a special character and is not included on the command line for commands (such as sed), instead, it is a pipe. But here, sed wants to think | is a file. Now, if I omit one quote, everything wo...

90's Game -- Spielberg's "Director's Chair"
This seems like a long shot (get it...long shot?) but is anybody reading this group familiar with a game called Steven Spielberg's Director's Chair from the mid-nineties? Actually, it's more of a movie- studio familiarizer than a game, per se, but it does have its strong points in terms of recreating a certain, Hollywood-y atmosphere. I'm curious because, when I run this program on a Windows 2000 box, I keep hitting an "Internal Error" during my first dip in The Lab. I can hear the first line of dialogue repeat about three times, then it shuts me down. Becau...

'Here's the thing about Apple's "recent"�success.'
'It isn't recent. The only thing that has changed are some numbers. Some big numbers: largest company in the world, second most profitable company in the world, most profitable retail stores in the world, best-selling smart phone, second best-selling smart phone, best-selling tablet computer, etc. Other numbers have not changed: customer satisfaction, customer loyalty, consumer ratings, etc.' <http://granthuhn.wordpress.com/2011/09/23/heres-the-thing-about-apples-r ecent-success/> -- "The iPhone doesn't have a speaker phone" -- "I checked very carefully" -- "I checked Apple's web pages" -- Edwin on the iPhone "It is Mac OS X, not BSD.' -- 'From Mac OS to BSD Unix." -- "It's BSD Unix with Apple's APIs and GUI on top of it' -- 'nothing but BSD Unix' (Edwin on Mac OS X) '[The IBM PC] could boot multiple OS, such as DOS, C/PM, GEM, etc.' -- 'I claimed nothing about GEM other than it was available software for the IBM PC. (Edwin on GEM) 'Solaris is just a marketing rename of Sun OS.' -- 'Sun OS is not included on the timeline of Solaris because it's a different OS.' (Edwin on Sun) "Alan Baker" wrote in message news:alangbaker-70BC8E.10314523092011@news.shawcable.net... 'It isn't recent. The only thing that has changed are some numbers. Some big numbers: largest company in the wor...

[OT] Nit: please don't user "it's" unless you can substitute "it is" without changing your inteded meaning.
Typos happen to all of us, but in case you hadn't realized what "it's" is a contraction for ("it is"), now you do, and you can save yourself further embarrassment (assuming you care ;-). If your friends won't tell you, who will ;-) Write the contraction "it's" only when you want its meaning to be "it is," otherwise it's wrong ;-) OTOH, how does one punctuate the posessive of a word per se? E.g., the first letter of "it" is "i", but can one write that as "it"'s first letter is "i," or it...

What's with the "OK's?"
Picked up ToEE from EB for 10\$. Installed it, hated the 3d/2d engine, loathed the pathfinding with more than 5 members, was quite sceptical of the interface, but had some fun with the combat engine which is fairly addicting, but was shocked that yet again a fantasy RPG has characters that say "OK." I understand that the characters in these games must speak english and that it has to be reasonably vernacular to appeal to everyone the publishers/developers want to buy the game, but OK is a colloquialism in the Fantasy RPG context I cannot abide. My frustrating few minutes with Never...

Help! Can't read file with the char's. " / " and "." !
&nbsp; Hi fellows! &nbsp; I got this file : example.&nbsp;&nbsp; &nbsp; 13-06-06 12:30:20,526&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-3,568&nbsp; 13-06-06 12:30:20,529&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-13,528 13-06-06 12:30:20,556&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-30,568 .. .. ..&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; My program writes this file, and in my program i also got a&nbsp; ReadFile.VI, to read this file and plot the data and i had no problem with that. Then I tried in another computer&nbsp; (with&nbsp;american english characters) . then when &nbsp;my program writes a&nbsp;file there I got the file look like this: &nbsp; 13/06/06 12:30:20.526&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-3.568&nbsp; 13/06/06 12:30:20.529&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-13.528 13/06/06 12:30:20.556&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-30.568 .. .. You can see that the caharacters "- " and&nbsp;", " are replaced with "/ " and&nbsp;". " Then when want to read&nbsp;this file with in my ReadFile.VI, the scan string&nbsp;comes with an error. So I managed this problem with&nbsp;replacing the american char's&nbsp;with the eurpaen char's....

Suddenly Can't Use "ifstream"s and "ofstream"s
I had a working piece of code that successfully read from files with the "ifstream" type and wrote to files with the "ofstream" type. This code is made up of a number of different files. In the course of the job I needed for two of these files to have access to one piece of information, so I created a class that I called "CSuffix" and stored the common information there. So I created a "Suffix.h" file that looks like: #pragma once class CSuffix { public: static void initialize (); static void increment (); static c...

What's the difference between "JDK" and "JRE"?
It seems both have a java.exe which can be used to execute the byte code(.class) but then jre does not have the javac compiler. broli wrote: > It seems both have a java.exe which can be used to execute the byte > code(.class) but then jre does not have the javac compiler. You basically answered your own question. -- Sabine Dinis Blochberger Op3racional www.op3racional.eu broli wrote: > It seems both have a java.exe which can be used to execute the byte > code(.class) but then jre does not have the javac compiler. Google is your friend http://www.google.com/search?q=jre+jdk+di...

My gtar run -- ended with "auto-logout". What's that, what's it mean?
Here's what I did, and the returned message: (A bit hard to read, with such wide lines. Sorry.) --- here it is: # date && id && cd /taperestore && pwd && gtar cvXf /exclude-from-tar.txt /dlink/gtar-backup-of---taperestore---801am-16aug12.gtar . > /dlink/gtar-backup-of---taperes\ tore---801am-16aug12.gtar.tar date && id && cd /taperestore && pwd && gtar cvXf /exclude-from-tar.txt /dlink/gtar-backup-of---taperestore---801am-16aug12.gtar . > /dlink/gtar-backup-of---taperesto\ re---801am-...

In xml schema, what's the difference between attribute "final" and "block" in element "element"
That is, what's the difference between <complexType name="Address" final="restriction"> <sequence> <element name="name" type="string"/> <element name="street" type="string"/> <element name="city" type="string"/> </sequence> </complexType> and <complexType name="Address" block="restriction"> <sequence> <element name="name" type="string"/> <element name="street" type="string"/> <element name="city" type="string"/> </sequence> </complexType> in xml schema? Hi, You can think of final as a development time restriction (applies to schema itself) and of block as a runtime restriction (applies to schema usage from the instance documents). If you have final="restriction" (note that I made city optional to have something to restrict) <xs:complexType name="Address" final="restriction"> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="street" type="xs:string"/> <xs:element name="city" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:complexType> then trying to create a type like below will fail with a...