1 \ #ident "%Z%%M% %I% %E% SMI"
2 \ Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 \ Use is subject to license terms.
7 \ The contents of this file are subject to the terms of the
8 \ Common Development and Distribution License, Version 1.0 only
9 \ (the "License"). You may not use this file except in compliance
12 \ You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
13 \ or http://www.opensolaris.org/os/licensing.
14 \ See the License for the specific language governing permissions
15 \ and limitations under the License.
17 \ When distributing Covered Code, include this CDDL HEADER in each
18 \ file and include the License file at usr/src/OPENSOLARIS.LICENSE.
19 \ If applicable, add the following below this CDDL HEADER, with the
20 \ fields enclosed by brackets "[]" replaced with your own identifying
21 \ information: Portions Copyright [yyyy] [name of copyright owner]
26 ." Interactive begin .. while .. repeat: "
27 " no loop (1) " 1 begin 0 while 1- repeat .passed?
28 " loop to 0 (1)" 9 begin dup while 1- repeat 0= .passed?
30 ." Compiled begin .. while .. repeat: "
31 : btest1 1 begin 0 while 1- repeat .passed? ;
32 : btest2 9 begin dup while 1- repeat 0= .passed? ;
33 " no loop (2) " btest1
34 " loop to 0 (2)" btest2
36 ." Interactive begin..until: "
37 " no loop (3)" 1 begin dup until .passed?
38 " loop to 0 (3)" 9 begin 1- dup 0= until 0= .passed?
40 ." Compiled begin..until: "
41 : btest3 1 begin dup until .passed? ;
42 : btest4 9 begin 1- dup 0= until 0= .passed? ;
44 " loop to 0 (4)" btest4
46 ." Interactive do .. loop: "
47 " loop (1)" 0 h# 10 0 do drop i loop h# f = .passed?
48 " no loop (1)" 1 0 0 ?do 1- loop .passed?
49 " leave (1)" h# 10 0 do i 5 = if 1 leave drop 0 then loop .passed?
51 ." Compiled do .. loop: "
52 : loop1 do drop i loop h# f = .passed? ;
53 : loop2 ?do 1- loop .passed? ;
54 : loop3 do i 3 = if drop i leave 0 then loop ;
55 : loop7 do i 4 = if drop i unloop exit then loop ;
56 " loop (2)" 0 h# 10 0 loop1
57 " no loop (2)" 1 0 0 loop2
58 " leave (2)" 3 4 0 loop3 3 = .passed?
59 " unloop" 5 6 0 loop7 4 = .passed?
61 ." Interactive do .. +loop: "
62 " loop by 2" 0 h# 10 0 do drop i 2 +loop h# e = .passed?
63 " loop down by 2" 0 -2 h# 10 do drop i -2 +loop h# -2 = .passed?
65 ." Compiled do .. +loop: "
66 : loop4 0 h# 10 0 do drop i 2 +loop h# e = .passed? ;
67 : loop5 0 -2 h# 10 do drop i -2 +loop -2 = .passed? ;
72 : loop6 0 h# 4 0 do 8 0 do 1 j 3 lshift i + lshift xor loop loop ;
73 " i,j sum" loop6 lwsplit over = swap h# ffff = and .passed?
75 ." Negative Limit Loops: "
76 " loop.7" h# 10 -37 8 bounds do drop i loop -30 = .passed?
77 " loop.8" h# 10 -37 -30 do drop i -1 +loop -37 = .passed?
79 ." Compiled begin...again: "
80 : loop9 begin true exit again false ; loop9 " loop9" rot .passed?
85 out-count 1+ to out-count
89 then in-count 1+ to in-count
96 " loop.10" loop10 in-count 10 = out-count 1 = and .passed?