## Search found 14 matches

Wed May 08, 2013 1:57 pm
Forum: Scheme
Topic: Evaluate arithmetic infix operators
Replies: 2
Views: 10739

### Re: Evaluate arithmetic infix operators

Also for more complex cases like ( ((2+1) +3*4) * (5+6))
Wed May 08, 2013 1:52 pm
Forum: Scheme
Topic: Evaluate arithmetic infix operators
Replies: 2
Views: 10739

### Evaluate arithmetic infix operators

I need to write a program with the following criteria: Returns either a value or the word "ERROR" Returns a value if it is called with a list that contains: A single number, or` An "ADD" ("+") command or "MULTIPLY" ("*") command in infix notation where the two operands must be recursively evaluated ...
Thu Mar 03, 2011 1:11 pm
Forum: Scheme
Topic: List Struture Equality
Replies: 10
Views: 21989

### Re: List Struture Equality

Forget it, I found what it was.

Does consp work with Dr Racket? I'm not home, so I can't try.
Thu Mar 03, 2011 12:21 pm
Forum: Scheme
Topic: List Struture Equality
Replies: 10
Views: 21989

### Re: List Struture Equality

Whats is the difference between cons and consp?
Wed Mar 02, 2011 7:38 pm
Forum: Scheme
Topic: Using And
Replies: 2
Views: 5965

### Using And

Lets say we have:

((and (something1)(something2)(something3)(something4)) #t)

How does it compute it, does it test if all four are true or does it in pairs like:

((something1)and(something2)=true and((something3)and(something4)=true)) Then the whole thing is true???

Thanks.
Wed Mar 02, 2011 6:39 pm
Forum: Scheme
Topic: List Struture Equality
Replies: 10
Views: 21989

### Re: List Struture Equality

Sorry I couldn't understand the last part

You mean Cons((function(car list)) (function(cdr list))

or something like that?
Wed Mar 02, 2011 4:50 pm
Forum: Scheme
Topic: List Struture Equality
Replies: 10
Views: 21989

### List Struture Equality

Hi, Ok I need some help with thinking through this conceputally. I need to check if a list and another list is structurally equal. For example: (a (bc) de)) is the same as (f (gh) ij)), because they have the same structure. Now cleary the base case will be if both list are empty they are structurall...
Fri Feb 18, 2011 8:16 am
Forum: Scheme
Topic: Some Idea
Replies: 8
Views: 16416

### Re: Some Idea

ok so when I do that it only returns true and not how many zeros there is?
> (countzeros '(0))
#t
> (countzeros (list 0))
#t
> (countzeros '(0 0))
#t
>
Thu Feb 17, 2011 7:43 pm
Forum: Scheme
Topic: Some Idea
Replies: 8
Views: 16416

### Re: Some Idea

I have no clue whats wrong. I get the error: procedure application: expected procedure, given: 0 (no arguments) code is: (define (countzeros list) (cond ((null? car list) 0) ((= (car list) 0 )) (+ 1 (countzeros(cdr list))) (else (countzeros(cdr list))))) I tried (countzeros (0)) Which should return ...
Tue Feb 15, 2011 9:48 am
Forum: Scheme
Topic: Some Idea
Replies: 8
Views: 16416

### Re: Some Idea

now that I think of this, wouldn't it be wrong.

Because if the car of the list is not equal to zero and we return 0, it will reset the count????