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
import codestory2013.gzoritchak.scalaskel.Coin.* | |
import java.util.* | |
enum class Coin(val value: Int) { | |
foo : Coin(1) | |
bar : Coin(7) | |
qix : Coin(11) | |
baz : Coin(21) | |
} |
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
package codestory2013.gzoritchak.jajascript | |
class Flight(val id: String, val startHour: Int, val duration: Int, val price: Int){ | |
val endHour = startHour + duration | |
} | |
class Planning(val gain: Int = 0, val flights: List<Flight> = listOf()) { | |
fun plus(flight: Flight) = Planning(gain + flight.price, flights + flight) //Planning + Flight = Planning | |
} |
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
package codestory2013.gzoritchak | |
import java.math.BigDecimal | |
import java.math.RoundingMode | |
import java.text.DecimalFormat | |
import java.text.DecimalFormatSymbols | |
import java.util.Locale | |
import java.util.StringTokenizer | |
import kotlin.math.* |
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
data class Soldier(val position: Int, var state:State = State.Living) { | |
fun suicide() { | |
state = State.Dead | |
} | |
fun isAlive() = state == State.Living | |
} | |
enum class State { | |
Living, Dead | |
} |
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
package org.gzk.marslander | |
val GRAVITY = acceleration(0.0, -3.711) | |
val maxX = 6999 | |
val minX = 0 | |
/** | |
* power : 0, 1, 2, 3, 4 | |
* angle : -90, -75, ... , 0, +15, +30, ..., +75, +90 | |
*/ |
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
package org.gzk.marslander | |
import java.lang.Math.* | |
/** | |
* A point in a 2 dimensions cartesian system. | |
* Point + Vector -> Point | |
* Point - Point -> Vector | |
*/ | |
data class Point(val x:Double, val y: Double) { |
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
package org.gzk.marslander | |
data class Time(val sec:Double) | |
val Double.sec: Time | |
get() = Time(this) | |
/** | |
* Speed is internally using a vector, allowing to compose it. speed12 = speed1 + speed2 | |
*/ |
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
package org.gzk.marslander | |
import java.lang.Math.random | |
val log = true | |
val elitism = true | |
val generationsCount = 10 | |
val populationSize = 20 | |
val genomeSize = 1200 |
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
package org.gzk.marslander | |
import java.io.StringReader | |
import java.util.* | |
fun main(args: Array<String>) { | |
val bestChimp = findBestChimp(::createMarsLander1FromGenome, ::marsLander1Fitness) | |
println( | |
bestChimp.result.trajectory.drop(1).joinToString (transform = { state -> "${state.angle}, ${state.power}" }) | |
) |
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
package jug.dsl | |
val kotlinSurveyDef = createNewSurveyDef("Évaluation du kotlin user group") { | |
introduction = "Merci de prendre 20 secondes pour répondre à quelques questions." | |
val appreciation = intQuestion("Quelle est votre appréciation de la dernière session ?"){ | |
min = 1 | |
max = 5 | |
} |
OlderNewer