mardi 26 février 2019

Testing in Scala (99 Scala problems)

I have just started a new job as an apprentice and have been tasked with learning scala. I have a very limited skillset in programming and the online material for learning scala as a beginner is limited. Could you guys walk me through the process of writing tests for the following problems as basically as you can as I learn well by example. Thanks in advance for your time and contributions :) ...

1) Find the last element of a list. Example: scala> last(List(1, 1, 2, 3, 5, 8)) res0: Int = 8

2) Find the last but one element of a list. Example: scala> penultimate(List(1, 1, 2, 3, 5, 8)) res0: Int = 5

3) Find the Kth element of a list. By convention, the first element in the list is element 0. Example:

scala> nth(2, List(1, 1, 2, 3, 5, 8)) res0: Int = 2

These are 3 of the "99 Scala Problems",hopefully this will help me complete the rest by myself.

Aucun commentaire:

Enregistrer un commentaire