Skip to content

Instantly share code, notes, and snippets.

View Willyfrog's full-sized avatar

Guillermo Vayá Willyfrog

View GitHub Profile
@Willyfrog
Willyfrog / conceptos.py
Created November 21, 2015 11:40
introduccion al python funcional
def trampolin(fun, *args, **kwargs):
result = [fun, args, kwargs]
while es_fun(result):
(fn, fun_args) = (result[0], result[1])
if (len(result) == 3):
fun_kwargs = result[2]
else:
fun_kwargs = {}
result = fn(*fun_args, **fun_kwargs)
@Willyfrog
Willyfrog / gist:7384126
Created November 9, 2013 10:33
Common lisp function for reading input, usefull for hakerrank challenges
(defun get-hr-parameters (&optional (coerce #'identity))
"gets all the parameters and puts them in a list"
(loop
for input-line = (read-line t nil :eof)
until (eq input-line :eof)
collect (funcall coerce input-line)))
@Willyfrog
Willyfrog / gist:7374943
Created November 8, 2013 17:55
simple examples of closures ;)
def myitemgetter(*args):
def fun(x):
return tuple([x[v] for v in args])
return fun
def suma_esto(x):
def fun(y):
return x + y
@Willyfrog
Willyfrog / virtualenv-auto-activate.sh
Created August 1, 2012 12:57 — forked from codysoyland/virtualenv-auto-activate.sh
virtualenv-auto-activate-auto-deactivate
#!/bin/bash
# virtualenv-auto-activate.sh
#
# Installation:
# Add this line to your .bashrc or .bash-profile:
#
# source /path/to/virtualenv-auto-activate.sh
#
# Go to your project folder, run "virtualenv .venv", so your project folder
# has a .venv folder at the top level, next to your version control directory.