How to use double do loop in Scheme? -


  1. 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 show3as result. did wrong? how should correct it?

to michael vehrs,

  1. 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?

  2. so "list" command can combine several variables. how "newline" command? tried remove , add () in last.

  3. 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

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -