How to use double do loop in Scheme? -
- i want use "do" command show - (1 1)(1 2)(1 3)(2 1)(2 2)(2 3)(3 1)(3 2)(3 3), code below:- (lambda ( ) (define 1) (define b 1) (do ((a 1 (+ 1))) (= 3) (do ((b 1 (+ b 1))) (= b 3) (display b) )))- but show - 3as result. did wrong? how should correct it?
to michael vehrs,
thank lot, works! i'm still confusing exit condition. tried change the
>in code to=and shows(1 1)(1 2)(2 1)(2 2). because stops when = 3 won't print?
so "list" command can combine several variables. how "newline" command? tried remove , add
()in last.
thank answer. i'm new scheme learner trying use on tracepro. have tip(book, youtube video, website) me learning scheme? advise help.
you mean:
  (lambda ()     (do ((a 1 (+ 1)))         ((> 3) (newline))       (do ((b 1 (+ b 1)))           ((> b 3))         (display (list b)))))) your code has number of problems: exit condition do loop incorrect (and makes procedure return 3). display takes single object , optional port arguments. defining variables a , b unnecessary, since do construct defines new loop variables anyway.
Comments
Post a Comment