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
from Stack import Stack | |
def is_operand(token): | |
""" | |
checks if token consists completely of digits or letters | |
:return: true if token is either all digit or all letters (case insensitive), false otherwise | |
""" | |
return token.isalpha() or token.isdigit() |
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 Password private constructor(val value: String) { | |
companion object { | |
fun of(value: String): Password? { | |
return if (value.isAGoodPassword()) Password(value) else null | |
} | |
} | |
} |
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 Password private constructor(val value: String) { | |
companion object { | |
fun of(value: String): Either<Violation, Password> { | |
return when { | |
value.isTooShort() -> Violation.PasswordTooShort(MIN_LENGTH).left() | |
value.containsNoNumbers() -> Violation.PasswordContainsNoNumbers.left() | |
else -> Password(value).right() | |
} | |
} | |
} |
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 Password private constructor(val value: String) { | |
companion object { | |
fun of(value: String): Password { | |
return when { | |
value.isTooShort() -> throw PasswordTooShortException() | |
value.containsNoNumbers() -> throw PasswordContainsNoNumbersException() | |
else -> Password(value) | |
} | |
} | |
} |
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 Password private constructor(val value: String) { | |
companion object { | |
fun of(value: String): Either<List<Violation>, Password> { | |
val violations = buildList { | |
if (value.isTooShort()) { add(Violation.PasswordTooShort(MIN_LENGTH)) } | |
if (value.containsNoNumbers()) { add(Violation.PasswordContainsNoNumbers) } | |
} | |
return if (violations.isEmpty()) Password(value).right() else violations.left() | |
} | |
} |
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
val password = Password.of("Some34Really434Hard21Password!").orThrow() //Throw on violation just for demonstration | |
val haha = password.copy(value = "gotcha") |
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
@NoCopy | |
data class Password private constructor(val value: String) { | |
companion object { | |
fun of(value: String): Either<List<Violation>, Password> { | |
val violations = buildList { | |
if (value.isTooShort()) { add(Violation.PasswordTooShort(MIN_LENGTH)) } | |
if (value.containsNoNumbers()) { add(Violation.PasswordContainsNoNumbers) } | |
} | |
return if (violations.isEmpty()) Password(value).right() else violations.left() | |
} |
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
val password = Password.of("Some34Really434Hard21Password!").orThrow() //Throw on violation just for demonstration | |
val haha = password.copy(value = "gotcha") //Unresolved reference: copy |
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 org.jetbrains.kotlin.gradle.tasks.KotlinCompile | |
plugins { | |
id "org.jetbrains.intellij" version "0.7.3" | |
id "org.jetbrains.kotlin.jvm" | |
} | |
repositories { | |
mavenCentral() | |
maven { |
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 com.dequeue.app.common.log | |
import com.dequeue.app.common.logging.D | |
import io.ktor.client.* | |
import io.ktor.client.plugins.* | |
import io.ktor.client.plugins.contentnegotiation.* | |
import io.ktor.client.plugins.logging.* | |
import io.ktor.client.plugins.resources.* | |
import io.ktor.serialization.kotlinx.json.* | |
fun ktorHttpClient(baseUrl: String): HttpClient = ktorClient { |