Ant task - longer examples update; Maze doesn't compile, HtmlBuilder doesn't run; Ivy configuration files updated to use public TeamCity; Wiki update

This commit is contained in:
Evgeny Goldin
2012-02-15 20:45:46 +02:00
parent c643b1cf45
commit 504beac0fa
8 changed files with 56 additions and 50 deletions
@@ -73,6 +73,7 @@ fun bottlesOfBeer(count : Int) : String =
* An excerpt from the Standard Library
*/
// From the std package
// This is an extension property, i.e. a property that is defined for the
// type Array<T>, but does not sit inside the class Array
@@ -144,4 +144,3 @@ fun html(init : HTML.() -> Unit) : HTML {
// An excerpt from the Standard Library
fun <K, V> Map<K, V>.set(key : K, value : V) = this.put(key, value)
+5 -3
View File
@@ -146,20 +146,22 @@ fun makeField(s : String) : Field {
return Field(w.size, lines.size) {i, j -> data[i][j]}
}
// An excerpt from the Standard Library
val String?.indices : IntRange get() = IntRange(0, this.sure().size)
fun <K, V> Map<K, V>.set(k : K, v : V) { put(k, v) }
fun comparator<T> (f : (T, T) -> Int) : Comparator<T> = object : Comparator<T> {
override fun compare(o1 : T, o2 : T) : Int = f(o1, o2)
override fun equals(p : Any?) : Boolean = false
override fun compare(o1 : T, o2 : T) : Int = f(o1, o2)
override fun equals(p : Any?) : Boolean = false
}
val <T> Array<T>.isEmpty : Boolean get() = size == 0
fun <T, C: Collection<T>> Array<T>.to(result: C) : C {
for (elem in this)
result.add(elem)
result.add(elem)
return result
}
+23 -21
View File
@@ -134,27 +134,28 @@ fun main(args : Array<String>) {
// UTILITIES
fun printMaze(str : String) {
val maze = makeMaze(str)
val maze = makeMaze(str)
println("Maze:")
val path = findPath(maze)
for (i in 0..maze.height - 1) {
for (j in 0..maze.width - 1) {
val cell = #(i, j)
print(
if (maze.walls[i][j]) "O"
else if (cell == maze.start) "I"
else if (cell == maze.end) "$"
else if (path != null && path.contains(cell)) "~"
else " "
)
}
println("")
}
println("Result: " + if (path == null) "No path" else "Path found")
println("")
println("Maze:")
val path = findPath(maze)
for (i in 0..maze.height - 1) {
for (j in 0..maze.width - 1) {
val cell = #(i, j)
print(
if (maze.walls[i][j]) "O"
else if (cell == maze.start) "I"
else if (cell == maze.end) "$"
else if (path != null && path.contains(cell)) "~"
else " "
)
}
println("")
}
println("Result: " + if (path == null) "No path" else "Path found")
println("")
}
/**
* A maze is encoded in the string s: the big 'O' letters are walls.
* I stand where a big 'I' stands and the prize is marked with
@@ -207,18 +208,19 @@ fun makeMaze(s : String) : Maze {
return Maze(w.size, lines.size, data, start.sure(), end.sure())
}
// An excerpt from the Standard Library
val String?.indices : IntRange get() = IntRange(0, this.sure().size)
fun <K, V> Map<K, V>.set(k : K, v : V) { put(k, v) }
fun comparator<T> (f : (T, T) -> Int) : Comparator<T> = object : Comparator<T> {
override fun compare(o1 : T, o2 : T) : Int = f(o1, o2)
override fun equals(p : Any?) : Boolean = false
override fun compare(o1 : T, o2 : T) : Int = f(o1, o2)
override fun equals(p : Any?) : Boolean = false
}
fun <T, C: Collection<T>> Array<T>.to(result: C) : C {
for (elem in this)
result.add(elem)
result.add(elem)
return result
}