Groovy / Scala highlighting
This commit is contained in:
parent
09bda14096
commit
a81b0a6f49
6 changed files with 457 additions and 2 deletions
47
index.html
47
index.html
|
|
@ -35,6 +35,8 @@
|
|||
<option value="clojure">Clojure</option>
|
||||
<option value="ocaml">OCaml</option>
|
||||
<option value="textile">Textile</option>
|
||||
<option value="groovy">Groovy</option>
|
||||
<option value="scala">Scala</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -62,6 +64,8 @@
|
|||
<option value="csharp">C-Sharp</option>
|
||||
<option value="svg">SVG</option>
|
||||
<option value="textile">Textile</option>
|
||||
<option value="groovy">Groovy</option>
|
||||
<option value="scala">Scala</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -631,6 +635,49 @@ bg. Blockquote!
|
|||
|
||||
</script>
|
||||
|
||||
<script type="text/editor" id="groovy">
|
||||
//http://groovy.codehaus.org/Concurrency+with+Groovy
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
def counter = new AtomicInteger()
|
||||
|
||||
synchronized out(message) {
|
||||
println(message)
|
||||
}
|
||||
|
||||
def th = Thread.start {
|
||||
for( i in 1..8 ) {
|
||||
sleep 30
|
||||
out "thread loop $i"
|
||||
counter.incrementAndGet()
|
||||
}
|
||||
}
|
||||
|
||||
for( j in 1..4 ) {
|
||||
sleep 50
|
||||
out "main loop $j"
|
||||
counter.incrementAndGet()
|
||||
}
|
||||
|
||||
th.join()
|
||||
|
||||
assert counter.get() == 12
|
||||
</script>
|
||||
|
||||
<script type="text/editor" id="scala">
|
||||
//http://www.scala-lang.org/node/227
|
||||
/* Defines a new method 'sort' for array objects */
|
||||
object implicits extends Application {
|
||||
implicit def arrayWrapper[A : ClassManifest](x: Array[A]) =
|
||||
new {
|
||||
def sort(p: (A, A) => Boolean) = {
|
||||
util.Sorting.stableSort(x, p); x
|
||||
}
|
||||
}
|
||||
val x = Array(2, 3, 1, 4)
|
||||
println("x = "+ x.sort((x: Int, y: Int) => x < y))
|
||||
}
|
||||
</script>
|
||||
<input id="cockpitInput" type="text"/>
|
||||
|
||||
<script src="demo/require.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue