sorry I'm new to this
is this the right idea? And can you tell me if I placed the () right?
(DEFINE (countzeros list)
(IF (<>(car(list)0)
0
(+1(countzeros(cdr(list)))
))
Thanks.
Search found 14 matches
- Tue Feb 15, 2011 8:41 am
- Forum: Scheme
- Topic: reversing a list
- Replies: 3
- Views: 12451
reversing a list
Ok so I need to remove the last item of a list.
ie : (1 2 3 4)
I will get
(1 2 3)
my idea is as follows:
reverse(list)
car(list)
reverse(list)
however I don't know if there is simple function in scheme(racket) that does reverse?
If not, is there an easier way to approach this problem?
Thanks.
ie : (1 2 3 4)
I will get
(1 2 3)
my idea is as follows:
reverse(list)
car(list)
reverse(list)
however I don't know if there is simple function in scheme(racket) that does reverse?
If not, is there an easier way to approach this problem?
Thanks.
Some Idea
Hey,
I need some help with a program. I don't expect anyone to write it for me. I just need help with the ideas or maybe some pseudo code to help me.
Problem:
Write a Scheme function that returns the number of zeros in a given simple list of numbers.
Thanks.
I need some help with a program. I don't expect anyone to write it for me. I just need help with the ideas or maybe some pseudo code to help me.
Problem:
Write a Scheme function that returns the number of zeros in a given simple list of numbers.
Thanks.
- Thu Feb 10, 2011 1:38 pm
- Forum: Scheme
- Topic: simple question
- Replies: 1
- Views: 7376
simple question
Hi,
I have maybe 1 day of scheme/lisp experience, and glad I found this forum.
I have a simple question.
Ok I know theres a null for detecting an empty list. However I have no idea how to find how many elements in a list. ie: (a) would return 1. Is there like a count function?
Thanks.
I have maybe 1 day of scheme/lisp experience, and glad I found this forum.
I have a simple question.
Ok I know theres a null for detecting an empty list. However I have no idea how to find how many elements in a list. ie: (a) would return 1. Is there like a count function?
Thanks.