This file contains 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
def test_filtered_really_in_2(y, xs): | |
def pred(e): return e is y | |
return filter(pred, xs) |
This file contains 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
def really_in(y, xs): | |
if y is not True and y is not False: | |
'''thanks http://www.reddit.com/r/Python/comments/asmwr/python_boolean_coercion_gotchas/c0j7cd7?context=3''' | |
return y in xs | |
for x in xs: | |
if y is x: return True | |
return False | |
True in [1, 2, 3] # -> True |
This file contains 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
/* | |
* usage example: | |
* $('body').zIndices() | |
* | |
* Returns a hash with z-indices as keys whose corresponding | |
* values are elements with that z-index set. Any z-index <z> | |
* having more than one element will also be in the hash | |
* under the key '!<z>' (to be sorted together near the top), | |
* as well as the regular key, '<z>'. | |
*/ |
This file contains 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
################################################# | |
# currying and partial application in python # | |
# based on code from Simon Willison's geocoders # | |
################################################# | |
# curries fn, a function of exactly 2 parameters | |
def partial2(fn): | |
def inner1(arg2): | |
def inner2(arg1): | |
return fn(arg1, arg2) |
This file contains 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
http://en.wikipedia.org/wiki/Church_numerals#Church_pairs (example) | |
fst (pair a b) | |
\p.p (\x.\y.x) ((\x.\y.\z.z x y) a b) | |
\p.p (\x.\y.x) (\z.z a b) | |
??? | |
(\z.z a b) (\x.\y.x) | |
(\x.\y.x) a b | |
a |
NewerOlder