This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set<Document> added | |
// Featurizer f | |
// sc::parallelize : List<T> -> JavaRDD<T> | |
Stream<Tuple2<Integer,Vector>> featurizedStream = added.stream() | |
.map(d -> new Tuple2(d.getId(), f.vector(d))); | |
JavaRDD<Tuple2<Integer,Vector>> featurized = | |
sc.parallelize(featurizedStream.collect(Collectors.toList())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
profit :: [Int] -> Int | |
profit xs = f (head xs) 0 (tail xs) | |
where | |
f minVal maxDiff [] = maxDiff | |
f minVal maxDiff (x:xs) = f (min minVal x) (max maxDiff (x - minVal)) xs | |
-- O(n) time, O(1) memory |
NewerOlder