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
[2,4,6,8,10].find do |element| | |
element > 5 | |
end | |
#-> 6 | |
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
input = [(1,2), (3,4)] | |
expected_output = [2,4] | |
def first_way(input): | |
def get_second_thing(tuple): | |
return tuple[1] | |
return map(get_second_thing, input) | |
def second_way(input): | |
return map(operator.itemgetter(1), input) |
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
import Control.Monad.Instances | |
addStuff = do | |
a <- (*2) | |
b <- (+10) | |
return (a+b) | |
addStuffTwo = | |
(* 2) >>= (\a -> | |
(+ 10) >>= (\b -> |
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
class Foo | |
def self.wat | |
22 | |
end | |
end | |
Foo.new.class.wat #22 | |
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
describe "containment" do | |
it "checks a list for items matching a predicate" do | |
expect([1,2,3]).to include do |num| | |
num > 10 | |
end | |
end | |
end |
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
class WithInt c where | |
combinate :: Integral i => i -> c -> [(i,c,d)] | |
data Wut = Wut deriving (Show) | |
instance WithInt Wut where | |
combinate i w = if (i == 0) | |
then [] | |
else (i,w,999):combinate (i - 1) w |
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
class WithInt c where | |
combinate :: Integral i => i -> c -> [(i,c)] | |
class RTP c where | |
fromNothing :: Integral i => i -> [(i,c)] | |
data Wut = Wut deriving (Show) | |
data Foo = Foo deriving (Show) |
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
class Album < ARModelSomething | |
class Presenter | |
def detailed(album): | |
{title: album.title, | |
other: album.stuff | |
} | |
end | |
def sumary(album): | |
{ | |
fewer: things |
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
first :: State [String] Int | |
first = state $ \initialstate -> (0, initialstate) | |
appender to_emit to_append = (state $ \lateststate -> (to_emit, (show to_append):lateststate)) | |
histogram = do | |
firstanswer <- first | |
secondanswer <- appender "HI" firstanswer | |
appender 876 secondanswer |
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
from random import shuffle | |
to_clump = [0, 0.2, 5, 9, 9.1, 100, 100.2] | |
shuffle(to_clump) | |
def clump_same(comparables, distance_threshold): | |
def do_clump(so_far, current): | |
last_clump = so_far[-1] | |
lowest_in_last_clump = last_clump[0] | |
if (current - lowest_in_last_clump) < distance_threshold: |