100 doors: Difference between revisions
Content deleted Content added
added Ol |
|||
Line 7,325: | Line 7,325: | ||
l . ; |
l . ; |
||
</lang> |
</lang> |
||
=={{header|Ol}}== |
|||
<lang scheme> |
|||
(define (flip doors every) |
|||
(map (lambda (door num) |
|||
(mod (+ door (if (eq? (mod num every) 0) 1 0)) 2)) |
|||
doors |
|||
(iota (length doors) 1))) |
|||
(define doors |
|||
(let loop ((doors (repeat 0 100)) (n 1)) |
|||
(if (eq? n 100) |
|||
doors |
|||
(loop (flip doors n) (+ n 1))))) |
|||
(print "100th doors: " doors) |
|||
</lang> |
|||
Output: |
|||
<pre> |
|||
100th doors: (1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) |
|||
</pre> |
|||
=={{header|Onyx}}== |
=={{header|Onyx}}== |