Skip to content

Instantly share code, notes, and snippets.

@ahmedazizkhelifi
Created April 13, 2020 01:57
Show Gist options
  • Save ahmedazizkhelifi/ee171b497b06d55742165f6ec3f288dd to your computer and use it in GitHub Desktop.
Save ahmedazizkhelifi/ee171b497b06d55742165f6ec3f288dd to your computer and use it in GitHub Desktop.
L= [0,1,2,3,4,5,6,7,8,9]
def condition(x):
return x>4
L2 = list(filter(condition,L))
# >>> [5, 6, 7, 8, 9]
L3 = list(filter(lambda x : x > 4 , L ))
# >>> [5, 6, 7, 8, 9]
import numpy as np
np.fromfunction(lambda i,j : i-j, (3,3))
#array([[ 0., -1., -2.],
# [ 1., 0., -1.],
# [ 2., 1., 0.]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment