Search found 11 matches

by MadMuppet006
Tue Aug 01, 2017 4:23 am
Forum: Scheme
Topic: write to file
Replies: 0
Views: 47326

write to file

I am trying to write a mandelbrot set procedure to a ppm file. I can write the file ok and open it using gimp but the picture is not correct .. I am not sure what is wrong though my first impression is that I am writing the bytes the wrong way around .. edit: no its not that I have tried 3 different...
by MadMuppet006
Sun Jun 05, 2016 12:16 am
Forum: Scheme
Topic: problem with assoc
Replies: 7
Views: 28590

Re: problem with assoc

thanks a lot .. ya I feel like a dummy :) all good info thanks again
by MadMuppet006
Sat May 28, 2016 5:17 am
Forum: Scheme
Topic: problem with assoc
Replies: 7
Views: 28590

Re: problem with assoc

with a lot of help on irc groovy2shoes in particular I came up with (define a-list `((+ . ,0+)(* . ,0*)(- . ,0-)(/ . ,0/)(0^ . ,0^))) ;;; where 0+ etc are prewritten procedures could have used + - (define value (lambda (n) (if (atom- n) n (let ((op (car (cdr n)))) (let ((f (assq op a-list))) (if f (...
by MadMuppet006
Wed May 25, 2016 4:13 am
Forum: Scheme
Topic: problem with assoc
Replies: 7
Views: 28590

Re: problem with assoc

I have re written my code (define a-list `((+ ,0+)(* ,0*)(- ,0-)(/ ,0/))) and (define val- (lambda (n) (if (atom- n) n (lambda f (f (car n)(val- (car (cdr (cdr n))))) (assoc (car (cdr n)) a-list))))) ;;; or (define val (lambda (n) (if (atom- n) n (let ((f ((car (cdr (assoc (car (cdr n)) a-list))))))...
by MadMuppet006
Mon May 23, 2016 9:57 pm
Forum: Scheme
Topic: problem with assoc
Replies: 7
Views: 28590

problem with assoc

I am trying to write a calculator procedure for the little schemer .. I have one procedure that works (define value (lambda (n) (if (atom- n) n (if (eq? (car (cdr n)) '0+) (0+ (car n)(value (car (cdr (cdr n))))) (if (eq? (car (cdr n)) '0*) (0* (car n)(value (car (cdr (cdr n))))) (if (eq? (car (cdr n...
by MadMuppet006
Wed Oct 15, 2014 11:01 pm
Forum: Common Lisp
Topic: problem with iterative procedure
Replies: 3
Views: 8556

Re: problem with iterative procedure

thanks for the hands up .. after a few hiccups getting the parenthesis in the right places I got everything working http://pastebin.com/fJSVdiwu

any other ideas you would care to share on my code welcome.

appreciate the help thanks al.
by MadMuppet006
Mon Oct 13, 2014 10:03 pm
Forum: Common Lisp
Topic: problem with iterative procedure
Replies: 3
Views: 8556

problem with iterative procedure

I am trying to write a procedure to list in order a list of numbers .. I can write a proceudure that works using a recursive procedure but when I try it with an iterative procedure http://pastebin.com/BKzcX8P7 I get an error saying "not a real" I tried to write the procedure using scheme h...
by MadMuppet006
Thu Nov 10, 2011 1:33 pm
Forum: Scheme
Topic: help writing a max procedure
Replies: 4
Views: 13965

Re: help writing a max procedure

yeah just had a look at it this morning .. makes sense :)

thanks for the help ..
by MadMuppet006
Wed Nov 09, 2011 6:26 pm
Forum: Scheme
Topic: help writing a max procedure
Replies: 4
Views: 13965

Re: help writing a max procedure

found out what I was doing wrong putting ( ) around hold as in ((> (car l)(hold)) was causing the error .. I tried (define my-max (lambda ( l ) (define helper (lambda ( hold-value l ) (define bigger (lambda ( m n ) (if (> m n) m n))) (cond ((null? (cdr l)) (bigger hold-value (car l))) (else (if (> (...
by MadMuppet006
Wed Nov 09, 2011 1:47 pm
Forum: Scheme
Topic: help writing a max procedure
Replies: 4
Views: 13965

help writing a max procedure

I am trying to write a max procedure to return the largest number in a list. heres my code ;;;using cond (define my-max (lambda ( l ) (define helper (lambda ( hold l ) (cond ((null? (cdr l))hold) ((> (car l)(hold)) (helper (car l)(cdr l))) (else (helper (hold)(cdr l)))))) (helper 0 l))) ;;;using if ...