Kotlin is a statically typed programming language that compiles to JVM byte codes and JavaScript.
1
vote
0answers
13 views
Event-driven finite state machine DSL in Kotlin
I wrote a DSL for defining a finite state machine. My robotics team wants to use a state machine to manage the state of the subsystems on our robot, like the arms, drive train, lifter, etc. Each ...
4
votes
2answers
38 views
Maximise adjacent numbers in a functional style (PE#11)
What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the [provided] 20×20 grid? [source]
This solution works, and works effectively ...
2
votes
0answers
195 views
Console command parser for my custom Libgdx console (gamedev)
For a game I'm writing using LibGDX framework and Kotlin language, I've decided to make a dev console. This is a WIP line parser. Since there's already a decent amount of code written I've decided to ...
4
votes
1answer
48 views
Credit card / IMEI check digit in Kotlin
I recently had the need to implement Luhn's Algorithm in a Java/Kotlin application. I needed a function that would add the check digit to the string of a number like a credit card or IMEI. It could be ...
2
votes
1answer
30 views
Postponed Prime Sequence in Kotlin
Following my previous unbounded prime generator and a followup by Martin R, I've tested the waters in Kotlin by making an unbounded sieve.
To quote Martin R's wonderful explanation of the base ...
2
votes
0answers
41 views
Roman number converter in Kotlin
I'm learning kotlin and java. As a code-kata I wrote the roman to decimal converter. I'd be very grateful for code review.
I was trying to keep things simple and funcional. I'd especially appreciate ...
0
votes
0answers
25 views
Check the battery's charge level and emit an alert on low/high value
The following script check constantly the battery's charge level of the user's laptop via the acpi command. When such level reach a low/high value, the script will ...
1
vote
1answer
79 views
Counter with increment and decrement buttons
For my first Kotlin project, I'm implementing the Redux pattern with simple Increment and Decrement buttons and a text view to display the current value.
My main questions have to do with Kotlin and ...
1
vote
1answer
71 views
Iterate through a 2D array. Kotlin extension method
Simple extension method for Kotlin. Should perform an action on every element in a 2d array. i.e. An array of arrays.
I have made the assumption that because the receiver type is defined as an array ...
2
votes
1answer
51 views
Interface to the Force.com REST API
I'm implementing an interface to the Force.com REST API, with very specific ideas about which parts of the API I need. My problem is with testability of consumers of this API abstraction.
The first ...
4
votes
1answer
65 views
Number guessing game in Kotlin
Is this code missing any "Kotlinisms"?
I've just started learning Kotlin so I'm not yet familiar with the Kotlin way of doing things.
The program will guess a number you are thinking of.
...
3
votes
2answers
116 views
Cache of shared observables (Rx)
So the idea is to maintain a cache of shared Observables - accessible by a key - which if not present will produce one using the given factory.
The underlying shared Observable is accessed via an ...
5
votes
3answers
87 views
Max heap implementation in Kotlin
I wrote this class a while ago to learn Kotlin and heaps, so any tips (on either my code style or my heap algorithm) would be appreciated!
...
4
votes
1answer
140 views
Stateless 2048 Game
I created a little Kotlin clone of the 2048 game that is playable in the console. My goals were readability and statelessness for no other reason than practice. Consider it a code kata wherein I didn'...
3
votes
1answer
626 views
Simple thread-safe loading cache based on RxJava
I'm sketching a simple thread-safe cache which can load missing values. It is based on RxJava's Observable which also means that it should be possible for a client to join a request for value which is ...
2
votes
0answers
183 views
Converting SpriteSheet Metadata .txt to .yaml
For practice I decided that I wanted to write an animation class for SpriteSheets. The problem is that a single Sprite can have different widths depending on the action they are drawn to act. A tool ...