-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#** | ||
* 整活性质的利用现有工具制作一个看起来很舒适的简单功能for循环 | ||
* 关于尝试将bang伪装的很先进 | ||
*# | ||
const For = (const match @ { | ||
*I [in] _ *Stop F { | ||
setres For[I in 0 .. Stop .. 1 F]; | ||
} | ||
*I [in] *Start _ *Stop F { | ||
setres For[I in Start .. Stop .. 1 F]; | ||
} | ||
*I [in] *Start _ *Stop _ *Step F { | ||
I = Start; while I < Stop { | ||
setres F[I]; | ||
I += Step; | ||
} | ||
} | ||
*I [of] @ F { | ||
inline@ Arg {{ | ||
take Builtin.Const[I `Arg`]; | ||
take F[]; | ||
}} | ||
} | ||
}); | ||
|
||
For! i in 1..@links ( | ||
print i; | ||
); | ||
print "---"; | ||
For! `I` of @copper @lead ( | ||
print I; | ||
); | ||
|
||
#* >>> | ||
set i 1 | ||
jump 5 greaterThanEq i @links | ||
print i | ||
op add i i 1 | ||
jump 2 lessThan i @links | ||
print "---" | ||
print @copper | ||
print @lead | ||
*# |