Execute Brain****: Difference between revisions

→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details
(→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details)
Line 1,990:
=={{header|Kotlin}}==
{{trans|Groovy}}
<lang scala>// version 1.1.12
 
class Brainf__k(val prog: String, val memSize: Int) {
private val mem = IntArray(memSize)
private var ip = 0
private var dp = 0
private val memVal get() = mem.getOrElse(dp) { 0 }
 
Line 2,009:
'[' -> handleLoopStart()
']' -> handleLoopEnd()
}
}
}
Line 2,023:
}
throw IllegalStateException("Could not find matching end bracket")
}
 
private fun handleLoopEnd() {
var depth = 0
Line 2,034:
}
throw IllegalStateException("Could not find matching start bracket")
}
}