Solves FilterArray and FilterArrayPositions

* Starts working on ArrayOfNElements
This commit is contained in:
2017-04-19 23:57:09 +02:00
parent c1d4c44209
commit e7ccf8c0b7
3 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
package functionalProgramming
/**
* Created by jleng on 4/19/2017.
* https://www.hackerrank.com/challenges/fp-array-of-n-elements
*/
class ArrayOfNElements {
}

View File

@@ -0,0 +1,9 @@
package functionalProgramming
/**
* Created by jleng on 4/19/2017.
* https://www.hackerrank.com/challenges/fp-filter-array
*/
class FilterArray {
def f(delim:Int,arr:List[Int]):List[Int] = arr.filter( _ < delim)
}

View File

@@ -0,0 +1,10 @@
package functionalProgramming
/**
* Created by jleng on 4/19/2017.
* https://www.hackerrank.com/challenges/fp-filter-positions-in-a-list
*/
class FilterArrayPositions {
def f(arr:List[Int]):List[Int] = for( (x, i) <- arr.zipWithIndex if i % 2 != 0) yield x
}