I hereby claim:
- I am 4fuss on github.
- I am 4fuss (https://keybase.io/4fuss) on keybase.
- I have a public key ASBLhmo9Srf1BYTfeMsn-ETG_amQSVgP54lWefsLKqCxtQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
d = {33: "Pipen", 13: "Jordan", 1: "Nobody", 4: "Walker"} | |
filtr = [33, 4] | |
{k: v for k, v in d.iteritems() if k in filtr} # {33: 'Pipen', 4: 'Walker'} |
val wordFrequencies = ("habitaul", 6) :: ("and", 56) :: ("consuetudinary", 2) :: ("additionally", 27) :: ("homely", 5) :: ("society", 13) :: Nil | |
//verbose implementation - two iterations one for filter and one for map | |
def wordsWithoutOutliers(wordFrequencies: Seq[(String, Int)]): Seq[String] = | |
wordFrequencies.filter{case (w, f) => f > 3 && f <25}.map{ case (w,f) => w } | |
//defining partial function using anonymous function pattern matching | |
val pf: PartialFunction[(String, Int), String] = { | |
case (word, freq) if freq > 3 && freq < 25 => word | |
} |
val predicate: (String, Int) => Boolean = { case (_, f) => f > 3 && f < 25 } | |
val transformFn: (String, Int) => String = { case (w, _) => w } | |
predicate("lol", 5) //returns true |
val songTitles = List("Lay My Soul to Waste", "Shallow Grave", "Killer by Night", "Cold Dark Mourning") | |
//passing anonymous function (String => String) to map | |
songTitles.map(t => t.toLowerCase) | |
//same using placeholder syntax: | |
songTitles.map(_.toUpperCase) |
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(100); |