need help displaying 
Author Message
 need help displaying

(code for program is at end of message)
Just wondering if anyone could help me out.  Right now I have a program that
when you type in (column '(4 4 4)) displays
O O O O
O O O O
O O O X
but what I want it to do is display
O O O O
O O O O
X O O O
the place where the problem occurs is with my function called displayX.  I was
just wondering if anyone could help correct this problem, it would be greatly
appreciated.

Code for Program:
(define (column lis)
  (do (
       (count1 (length lis) (- count1 1)))
    ((= count1 1) (displayX lis))
    (display "O ")
    (row lis)
    (newline)
    ))

(define (row lis)
  (do (
       (count2 (first lis) (- count2 1)))
    ((= count2 2)(display "O "))
    (display "O ")))

(define (displayX lis)
  (do (
       (count3 (first lis) (- count3 1)))
   ((= count3 1)(display "X "))
    (display "O ")
    ))



Mon, 29 Apr 2002 03:00:00 GMT  
 need help displaying

Quote:

>(code for program is at end of message)
>Just wondering if anyone could help me out.  Right now I have a program that
>when you type in (column '(4 4 4)) displays
>O O O O
>O O O O
>O O O X
>but what I want it to do is display
>O O O O
>O O O O
>X O O O
>the place where the problem occurs is with my function called displayX.  I was
>just wondering if anyone could help correct this problem, it would be greatly
>appreciated.
>(define (row lis)
>  (do (
>       (count2 (first lis) (- count2 1)))
>    ((= count2 2)(display "O "))
>    (display "O ")))

Why do you specify (display "O ") in two places?  Why not do:

(define (row lis)
  (do ((count2 (first lis) (- count2 1)))
      ((= count2 1))
    (display "O ")))

Did you think that an expression was required after the end-test?  It's not
-- you can have as many expressions as you want there, including none.

Also, your version would get into an infinite loop if (first lis) were 1,
since count2 would start out at 1, so (= count2 2) would never be true.

Quote:
>(define (displayX lis)
>  (do (
>       (count3 (first lis) (- count3 1)))
>   ((= count3 1)(display "X "))
>    (display "O ")
>    ))

You should display the X *before* the do-loop, not at the end of it.
What's so confusing about that?

(define (displayX lis)
  (display "X ")
  (do ((count3 (first lis) (- count3 1)))
      ((= count3 1))
    (display "O ")))

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



Mon, 29 Apr 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. need help displaying arabic text in Tcl/Tk 8.1 on Unix

2. Need help with LeadTools API and displaying image in image control

3. Need help with displaying calculations.

4. Need help to Display Parent/Child

5. Need help on displaying Master and Details window.

6. FlagShip: Need help on display data ?

7. Need help on displaying ASCII files

8. Help needed with DISPLAY

9. Help Needed displaying binary (COMP-3) numbers

10. Need help on decimals, DISPLAY

11. Need HELP with strange DISPLAY problem

12. Need Help in determining DISPLAY problem

 

 
Powered by phpBB® Forum Software