Skip to content

Instantly share code, notes, and snippets.

perm :: [Int] -> [ [Int]]
perm [] = return []
perm (x:xs) = do ys <- perm xs
zs <- insert x ys
return zs
insert :: a -> [a] -> [[a]]
insert x xs = (return (x:xs))
`mplus` case xs of
[] -> mzero
#+LaTeX_CLASS: beamer
#+MACRO: BEAMERMODE presentation
#+MACRO: BEAMERTHEME Antibes
#+MACRO: BEAMERCOLORTHEME lily
#+MACRO: BEAMERSUBJECT RMRF
#+TITLE: Gobernabilidad de T.I
#+AUTHOR: {Adolfo Builes \\ Santiago Bustamante}
* Sobre la gobernabilidad de T.I
pLettera :: Parser Char Char
pLettera = P (\inp -> case inp of
( s:ss )
| s == 'a' -> [('a',ss)]
| otherwise -> []
otherwise -> []
)
pLettera :: Parser Char Char
pLettera = P (\inp -> case inp of
( s:ss ) | s == 'a' -> [('a',ss)]
otherwise -> []
)
Agregar iluminación local a la escena (Fórmula de Gouraud)
Agregando las siguientes palabras claves al compilador:
- global_settings {ambient_light color White} (luz ambiental de toda la escena)
- finish {ambient 0.1} (Ka del objeto)
- finish {diffuse 0.7} (Kd del objeto)
def finishP = "finish" ~> "{" ~> ("ambient"|"difuse"|"phong"|"phong_size") ~ valueP <~ "}" ^^
{
case "ambient" ~ color => ("ambient" ,color)
case "difuse" ~ color => ("difuse" ,color)
case "phong" ~ color => ("phong" ,color)
case "phong_color" ~ color => ("phong_color" ,color)
case "size" ~ color => ("size" ,color)
}
newtype ZipList a = ZipList { getZipList :: [a] }
instance Functor ZipList where
fmap g (ZipList a) = ZipList $ fmap g a
instance Applicative ZipList where
pure a = ZipList [a]
(ZipList fs) <*> (ZipList xs) = ZipList $ zipWith ($) fs xs
Con este ejemplo
stereotype Property extens uml::Property
El identifier que es Property, lo reconoce como el token STEREOTYPE y no como IDENTIFIER :(.
Hay una opcion para evitar eso ?
grammar Textuml;
options{output=AST;}
tokens{
ATTRIBUTE;
CLASS;
CLASS_DEF;
FEATURE;
IN;
def specularIllumination(h: Hit, l: LightSource): Color3f = {
val direction = getLightDirection (h.location , l )
val reflected = reflectedVector (direction , h.normal )
val vrn = pow (reflected.dot(direction).toFloat , h.material.kn).toFloat;
// val temp = (new Color3f(1,1,1)).scale (h.material.ks)
val specular = vrn * h.material.ks
val color = ***(l.color, h.material.pigment)
color.scale (specular)
return color