Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

The Little Schemer

Name: Anonymous 2009-07-19 23:23

Hi, I am working through the little schemer. I do not have the math skills to work through SICP.

I have the following code:


(define (member? a lat)
  (lambda (a lat)
    (cond
      ((null? lat) #f)
      (else (or (eq? (car lat) a)
                (member? a (cdr lat)))))))



When I run this say like:
(member? 3 (cons 3 '(9 8 7 6 13 3)))

I get the following:
#<procedure:...my-scheme-log.ss:137:2>
rather than a list without the first instance of 3

Can you help me?

Name: =+=*=F=R=O=Z=E=N==V=O=I=D=*=+= !frozEn/KIg 2009-07-20 16:05

#include <stdio.h>
#include <stdlib.h>
//haskell style square function: it took far longer to debug then to write.

int multiplyArray(int *arr,int arrsize){
int res=arr[0];int x=0;
while(++x<arrsize){res*=arr[x];};return res;}

int* duplicateInts(int num,int count){
int *storeInts=calloc(count,sizeof(int));int loop;
for(loop=0;loop<count;loop++){storeInts[loop]=num;};return storeInts;}

void main(int argc,char **argv){printf("%i",multiplyArray(duplicateInts(atoi(argv[1])?atoi(argv[1]):0,2),2));}




___________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
Nature is busy creating absolutely unique individuals, whereas culture has invented a single mold to which all must conform. It is grotesque.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List