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
import java.util.Set; | |
import java.util.List; | |
import java.util.ArrayList; | |
interface SetObserver<E> { | |
void added(ObservableSet<E> set, E element); | |
} | |
public class ObservableSet<E> { |
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
main = animationOf mover | |
pared = color(solidRectangle (4,2),light yellow) | |
tejado = color(solidPolygon[(-2,1),(0,2),(2,1)],red) | |
puerta = translate(color(solidRectangle(0.6,1),brown),0,-0.5) | |
ventana1 = translate(color(solidRectangle(0.6,0.6),light blue),-1,0) | |
ventana2 = translate(color(solidRectangle(0.6,0.6),light blue),1,0) | |
mover a = rotate (casa,100*a) |
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
-- www.glc.us.es/~jalonso/exercitium/mayor-capicua-producto-de-dos-numeros-de-n-cifras | |
mayorCapicuaP n = alpha 0 (t-1) | |
where | |
t = 10^n | |
b = div t 10 | |
alpha a x | x > b = let a' = case beta x of | |
Just z -> max z a | |
Nothing -> a | |
in alpha a' (x-1) |
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://www.glc.us.es/~jalonso/exercitium/minimo-producto-escalar/ | |
import Data.List | |
----------------------------------------------------------------------------------------- | |
a <·> b = sum (zipWith (*) a b) | |
----------------------------------------------------------------------------------------- |
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
-- www.glc.us.es/~jalonso/exercitium/particiones-de-enteros-positivos/ | |
zen :: ([a] -> [a]) -> [a] -> [a] -> [a] | |
zen f a b = | |
let a' = f a | |
b' = b ++ a | |
in case a' of | |
[] -> b' | |
_ -> zen f a' b' |
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
module Letiscase where | |
data Tipo = TipoUno Int | |
| TipoDos Int | |
f (TipoUno x) = x | |
f (TipoDos x) = x | |
g t = case t of | |
TipoUno x -> x |
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
newtype Mu a = In (Mu a -> a) | |
out :: Mu a -> (Mu a -> a) | |
out (In f) = f | |
omega = \f->(out f) f | |
psi = \h -> \f-> h ((out f) f) | |
yfix = \i-> omega (In (psi i)) | |
factorial = yfix (\g-> \n->if n < 2 then 1 else n*( g (n-1))) |
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
import Data.List | |
-- alphabil = [0,0,0,0,1,1,1,2,2,2] | |
-- alphanob = [0,0,0,0,3,3,3,4,4,4] | |
alphabil = [0,0,0,1,1,2,2] | |
alphanob = [0,0,0,3,3,4,4] | |
betabil = {-nub-} (permutations alphabil) | |
betanob = {-nub-} (permutations alphanob) |
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://lucacardelli.name/Papers/BasicTypechecking.pdf **) | |
(** Modula 2 **) | |
(***************************************************************************) | |
(**************************** DEFINITION MODULES ***************************) | |
(***************************************************************************) | |
(***************************************************************************) | |
DEFINITION MODULE ErrorMod; | |
PROCEDURE Msg(msg: ARRAY OF CHAR); |
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 f(x): | |
def g(y): | |
def h1(z): | |
nonlocal x,y | |
x = z | |
y = 2*z | |
print(locals()) | |
def h2(z): | |
print(locals()) | |
return z+y+x |
OlderNewer