Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!gatech!newsjunkie.ans.net!howland.reston.ans.net!cs.utexas.edu!utnut!alchemy.chem.utoronto.ca!news
From: The Dark Knight <TheDarkKnight@WayneManor.Gotham>
Subject: HELP: 2 simple? problems for the SCHEMER in you!
Sender: news@alchemy.chem.utoronto.ca (USENET news)
Message-ID: <DGAyzH.9F7@alchemy.chem.utoronto.ca>
Date: Wed, 11 Oct 1995 21:14:05 GMT
X-Nntp-Posting-Host: slip4.chem.utoronto.ca
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
X-Mailer: Mozilla 1.2N (Windows; I; 16bit)
Organization: University of Toronto Chemistry Department
Lines: 38


Hi...I am just starting out in the new world of Scheme and am stuck on 
two problems:

Problem 1

Write a recursive procedure, (digit-0 x), to return the index (counting 
from 0) from the first digit that is 0 in the number x. If no digit is 0, 
then return -1.

(digit-0 0) => 0
(digit-0 1) => -1
(digit-0 902) => 1
(digit-0 2045) => 2

Problem 2

Funarg Corporation marks each of its cartons with a numeric code to 
indicate the number of items of each type inside the carton. The code 
consists of triples of digits. Each triple consists of two digits 
specifying the type of item, followed by one digit specifying the number 
of that item. There can be any number of different items. For example 
128934 specifies that there are 8 items of type 12 and 4 items of type 
93. Write the procedure (count-of-items code type) that returns the 
number of items of kind type specified in code. Return -1 if there are no 
items of that kind.


..If you know the answers to these problems then PLEASE post a response 
in this newsgroup...I don't have an E-mail account so don't try E-mailing 
me...Thanks in advance to the kind soul!



                        The Dark Knight exiteth...



