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
<?php | |
/** | |
* The template for displaying archive pages | |
* | |
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/ | |
* | |
* @package WordPress | |
* @subpackage Twenty_Nineteen | |
* @since Twenty Nineteen 1.0 | |
*/ |
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
interface BooBoo { | |
fun sayBoo(): String | |
} | |
data class Tanon(val char: String) : BooBoo { | |
override fun sayBoo(): String = char | |
} | |
data class Choon(val char: String) : BooBoo { | |
override fun sayBoo(): String = char + "ー" |
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
interface BooBoo { | |
fun sayBoo(): String | |
} | |
data class Tanon(val char: String) : BooBoo { | |
override fun sayBoo(): String = char | |
} | |
data class Choon(val char: String) : BooBoo { | |
override fun sayBoo(): String = char + "ー" |
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
tailrec fun <T, R> Iterable<T>.mapWithConsIter(result: Cons<R>, src: Iterator<T>, cb: (T) -> R): List<R> { | |
if (!src.hasNext()) { | |
return result | |
} | |
val e = src.next() | |
return mapWithConsIter(Cons<R>(cb(e), result), src, cb) | |
} |
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
fun double(vararg items: Int): List<Int> { | |
return items.map { it * it } | |
} |
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
fun main(argv: Array<String>) { | |
println(fib(1)) | |
println(fib(2)) | |
println(fib(10)) | |
println(fib(100)) | |
} | |
fun fib(end: Int): Long { | |
if (end == 0) { |
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
class Calculator { | |
val stack = mutableListOf<Int>() | |
fun pushOperand(operand: Int) { | |
stack.add(operand) | |
} | |
fun pushOperator(operand: String) { | |
when(operand) { | |
"+" -> { |
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
//基本問題 | |
fun main(args: Array<String>) { | |
(1..100).map{ | |
when { | |
it % 15 == 0 -> println("FizzBuzz") | |
it % 3 == 0 -> println("Fizz") | |
it % 5 == 0 -> println("Buzz") | |
else -> println(it) | |
} | |
} |
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
# 応用問題 | |
def main | |
values = (1..100).map {|i| | |
i_name = i.to_s | |
three = i_name =~ /3/ || i % 3 == 0 | |
five = i_name =~ /5/ || i % 5 == 0 | |
if three && five | |
'FizzBuzz' | |
elsif five | |
'Buzz' |
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
// 基本問題 | |
fun main(args: Array<String>) { | |
val values = generateFizzBuzz() | |
values.forEach { | |
println(it) | |
} | |
} | |
private fun generateFizzBuzz(): List<Any> { | |
val values = (1..100).map { |
NewerOlder