labeledLoop v0.1

0

Monthly downloads

0th

Percentile

Labeled Loop

Support labeled loop and escape from nested loop

Readme

LabeledLoop

A simple package for R providing a support for labeled loop. The semantics is similar with Java's labeled loop. The labeled loops can be nested.

Here is a basic example:

. %._.% for(i in 1:3) {  
  foo %._.% for (j in 1:3) {
    orz %._.% for (k in 1:3) {
      print(c(i, j, k))

      if (i == 3 && j == 3 && k == 2) {
        cat("escape from outmost loop\n")
        ._.() # break
      }

      if (i == 2 && j == 2) {
        cat("escape from innermost loop (orz)\n")
        ._.(orz) # break
      }

      if (i == 1 && j == 1 && k == 2) {
        cat("escape from foo\n")
        ._.(foo) # break
      }
    }
  }
}

Then, the output looks like:

[1] 1 1 1
[1] 1 1 2
escape from foo
[1] 2 1 1
[1] 2 1 2
[1] 2 1 3
[1] 2 2 1
escape from innermost loop (orz)
[1] 2 3 1
[1] 2 3 2
[1] 2 3 3
[1] 3 1 1
[1] 3 1 2
[1] 3 1 3
[1] 3 2 1
[1] 3 2 2
[1] 3 2 3
[1] 3 3 1
[1] 3 3 2
escape from outmost loop

Functions in labeledLoop

Name Description
%._.% Labeled loop and break
No Results!

Last month downloads

Details

Type Package
Date 2012-04-21
License MIT
Collate 'labeledLoop.R'
Packaged 2012-04-21 14:57:35 UTC; takahashi
Repository CRAN
Date/Publication 2012-04-21 15:09:31

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/labeledLoop)](http://www.rdocumentation.org/packages/labeledLoop)