Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // for マクロ
- macro @for ( it, enumerate, body )
- syntax ( "for", it, "in", enumerate, body )
- {
- <[
- {
- loop $it = first( $enumerate ), tail = rest( $enumerate ) {
- ~$body
- when null? tail {
- recur first( tail ), rest( tail )
- }
- }
- }
- ]>
- }
- // for マクロを使ったコード:
- for n in 1..10 {
- println( n )
- }
- // これは以下のように展開される(はず):
- {
- loop n = first( 1..10 ), tail = rest( 1..10 ) {
- println( n )
- when null? tail {
- recur first( tail ), rest( tail )
- }
- }
- }
Add Comment
Please, Sign In to add comment