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 17:12

#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
//this is how i envision haskell power (x^y) function to work with something like func=product.replicate x;
//Now with arbitrary precision(with GMP)

void multiplyArray(int *arr,int arrsize,mpz_t num){
int x=0;mpz_set_si(num,arr[0]);
while(++x<arrsize){mpz_mul_si(num,num,arr[x]);};}

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){
mpz_t num;mpz_init(num);
multiplyArray(duplicateInts(atoi(argv[1])?atoi(argv[1]):0,atoi(argv[2])?atoi(argv[2]):1),atoi(argv[2])?atoi(argv[2]):1,num);
mpz_out_str(stdout,10,num);}




____________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
I prefer to be true to myself, even at the hazard of incurring the ridicule of others, rather than to be false, and to incur my own abhorrence.

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