mirror of
https://github.com/jlengrand/hackerrank.git
synced 2026-03-10 08:21:24 +00:00
Solves FilterArray and FilterArrayPositions
* Starts working on ArrayOfNElements
This commit is contained in:
@@ -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 {
|
||||
|
||||
}
|
||||
9
src/main/scala/functionalProgramming/FilterArray.scala
Normal file
9
src/main/scala/functionalProgramming/FilterArray.scala
Normal 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)
|
||||
}
|
||||
@@ -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
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user