<commit_before>package i_introduction._8_Smart_Casts

import util.TODO
import util.doc8

interface Expr
class Num(val value: Int) : Expr
class Sum(val left: Expr, val right: Expr) : Expr

fun eval(e: Expr): Int =
        when (e) {
            is Num -> todoTask8(e)
            is Sum -> todoTask8(e)
            else -> throw IllegalArgumentException("Unknown expression")
        }

fun todoTask8(expr: Expr): Nothing = TODO(
    """
        Task 8.
        Rewrite 'JavaCode8.eval()' in Kotlin using smart casts and 'when' expression.
    """,
    documentation = doc8(),
    references = { JavaCode8().eval(expr) })
<commit_msg>task 8<commit_after>package i_introduction._8_Smart_Casts

import util.TODO
import util.doc8

interface Expr
class Num(val value: Int) : Expr
class Sum(val left: Expr, val right: Expr) : Expr

fun eval(e: Expr): Int {
    when (e) {
        is Num -> return e.value
        is Sum -> return eval(e.left)+ eval(e.right)
        else -> throw IllegalArgumentException("Unknown expression")
    }
}
fun todoTask8(expr: Expr): Nothing = TODO(
    """
        Task 8.
        Rewrite 'JavaCode8.eval()' in Kotlin using smart casts and 'when' expression.
    """,
    documentation = doc8(),
    references = { JavaCode8().eval(expr) })

{'fraction_non_alphanumeric': 0.12104430379746836, 'fraction_numerical': 0.013449367088607595, 'mean_word_length': 2.8333333333333335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2551523', 'n_tokens_mistral': 413, 'n_tokens_neox': 401, 'n_words': 120}