SlideShare a Scribd company logo
(defn f [x]
(* 2 x))
(defn vmap [f xs]
( letfn [ (recursividad [g g2 zs]
(if (empty? g2)
zs
(recursividad g
(rest g2)
(conj zs ( g (first g2))))
)
)] (recursividad f xs [] )))
(defn total-en [ xs]
(letfn [ (recursividad [ys ac]
(if (empty? ys )
ac
(recursividad (rest ys) (+ ac (first ys )))))]
(recursividad xs 0)))
(defn mmap [f xs]
(letfn [(recursividad [g g2 zs]
(if (empty? g2)
zs
(recursividad g
(rest g2)
(conj zs
[((first g2)0)
(g ( (first g2)1))]))))]
(recursividad f xs {})))
(defn filter [f xs]
(letfn [(recursividad [g ys zs]
(if (empty? ys)
zs
(recursividad g
(rest ys)
(if (g (first ys))
(conj zs (first ys)),zs))))]
(recursividad f xs [])))
(defn tiene-dos-elementos? [xs]
(== (count xs)2))
(defn tiene-dos-elementosV? [xs]
(and (vector? xs) (== (count xs)2)))
(defn rango [xs]
(or (and(>= xs 20) (<= xs 30)) (and (>= xs 40) (<= xs 50)))
)
(defn mfilter [f xs]
(letfn [(recursividad [g ys zs]
(if (empty? ys)
zs
(recursividad g
(rest ys)
(if (g (first ys)1)
(conj zs (first ys))
zs
))))]
(recursividad f xs {})))
(defn vreduce [f vi xs]
(letfn [(recursividad [g vf ys]
(if (empty? ys)
vf
(recursividad g
(g vf (first ys))
(rest ys))))]
(recursividad f vi xs)))
(defn vmap [f xs]
( letfn [ (recursividad [g g2 zs]
(if (empty? g2)
zs
(recursividad g
(rest g2)
(conj zs ( g (first g2))))
)
)] (recursividad f xs [] )))
(vmap (fn [x] (* 2 x)) [ 2 3 4])
[4 6 8]
(defn mmap [f zs]
(letfn [(recursividad [g g2 zs]
(if (empty? g2)
zs
(recursividad g
(rest g2)
(conj zs
[((first g2)0)
(g ( (first g2)1))])))]
=> (filter tiene-dos-elementos? [[10 20] [30] [40 50]])
[[10 20] [40 50]]
(defn filter [f xs]
(letfn [(recursividad [g ys zs]
(if (empty? ys)
zs
(recursividad g
(rest ys)
(if (g (first ys))
(conj zs (first ys)),zs))))]
(recursividad f xs [])))
(defn tiene-dos-elementos? [xs]
(== (count xs)2))
=> (filter tiene-dos-elementos? ["ho" "l" "a!"])
["ho" "a!"]
(defn tiene-dos-elementosV? [xs]
(and (vector? xs) (== (count xs)2)))
(filter tiene-dos-elementosV? [[10 20] 30 [40 50]])
[[10 20] [40 50]]
tiene-dos-elementosV?
(recursividad f xs {} )))
(defn rango [xs]
(or (and(>= xs 20) (<= xs 30)) (and (>= xs 40) (<= xs 50)))
)
(filter rango [10 15 25 40 30 27 42])
[25 40 30 27 42]
=> (filter (fn [xs]
(or (and(>= xs 20) (<= xs 30)) (and (>= xs 40) (<= xs 50)))
)[10 15 25 40 30 27 42])
[25 40 30 27 42]
=> (vreduce (fn [x y]
(+ x y))
0 [4 5 3])
12
=> (vreduce (fn [x y]
(* x y))
1 [4 5 3])
60
=> (vreduce (fn [x y]
(conj x [(count x)y]))
{} [10 20 30])
{0 10, 1 20, 2 30}
(ns plf23072016.core
(:require [plf23072016.fos :as fos] :reload ))
(defn duplicados [xs]
(fos/vmap (fn [x] ( * 2 x)) xs))
(clojure.string /trim "hola"
(defn duplicados [xs]
(fos/vmap (fn [x] (* 2 x))xs))
(ns proyecto03.core
(:require [proyecto03.fos :as fos] :reload) )
(defn duplicados [xs]
(fos/vmap (fn [x] (* 2 x))xs))
(duplicados [2 3 4])
[4 6 8]
//
(defn composicion-de [f g]
(fn [x]
(g (f x))))
=> (fos/composicion-de (fn [x] (* 2 x)) (fn [x] (* 3 x)))
=> ((fn [x y]
(letfn [(g [a v]
(if (empty? v)
a
(g (+ a (first v)) (rest v))))]
(g x y))) 0 [10 20 30])
60
=> ((fn [x y]
(letfn [(g [a v]
(if (empty? v)
a
(g (* a (first v)) (rest v))))]
(g x y))) 1 [10 10 10])
1000
18/07/2016
=> (letfn [(g [zs ys]
(if (empty? zs)
ys
(g (rest zs) (if (>= (count (first zs)) (count ys)) (first zs) ys ))))]
(g [[]] []))
[]
=> (letfn [ (f [x] (* 2 x))
(g [x] (* 3 x))])
nil
=> (letfn [ (f [x] (* 2 x))
(g [x] (+ (f x) (f x)))]
(g 5))
20
=> (letfn [(total-en [xs]
(letfn [(g [ys a]
(if (empty? ys)
a
(g (rest ys) (+ a (first ys)))))]
(g xs 0)))]
(total-en [10 20]))
30
=> (letfn [(total-en [xs]
(letfn [(g [ys a]
(if (empty? ys)
a
(g (rest ys) (+ a (first ys)))))]
(g xs 0)))
(f [xs]
(letfn [ (g [zs ys]
(if (empty? zs)
ys
(g (rest zs) (if (> (total-en ys) (total-en (first zs)))ys (first zs)))))]
(g xs [])))]
(f [ [21 13] [20] [10]]))
[21 13]
=> (conj [10 20] 30)
[10 20 30]
=> (conj [10 20 30 40 50] 30 )
[10 20 30 40 50 30]
=> (conj [10 20 30 40 50] [30] )
[10 20 30 40 50 [30]]
=> (let [xs [10 20]
ys (conj xs 30)]
[xs ys])
[[10 20] [10 20 30]]
=> (letfn [(g [xs ys]
(if (empty? xs)
ys
(g (rest xs) (conj ys (* 2 (first xs))))))]
(g [2 3 4 ] []))
[4 6 8]
=> (letfn [(g [xs ys]
(if (empty? xs)
ys
(g (rest xs) (conj ys (count(first xs))))))]
(g [[ 2 3 ] [ 4 5 6]] []))
[2 3]d
=> '("" "" "" "")
("" "" "" "")
=> '("" "" "" "")
("" "" "" "")
=> ["hola" true true 4.9 3/2]
["hola" true true 4.9 3/2]
=> [a e i "o" "u"]
[a e i "o" "u"]
=> {10 20 20 20 30 20 40 20}
{10 20, 20 20, 30 20, 40 20}
=> (true false false true
)
ClassCastException java.lang.Boolean cannot be cast to clojure.lang.IFn
proyecto03.core/eval8026 (form-init6206876087026402955.clj:1)
=> (true false false true)
ClassCastException java.lang.Boolean cannot be cast to clojure.lang.IFn
proyecto03.core/eval8028 (form-init6206876087026402955.clj:1)
=> { true false false true}
{true false, false true}
=> #{true false}
#{true false}
=> # {true false true}
RuntimeException Map literal must contain an even number of forms
clojure.lang.Util.runtimeException (Util.java:221)
=> (count ' (10 20 30 40))
4
=> (empty? ' (10 20 30 40))
false
=> (list? ' (10 20 30 40))
true
=> (vector? ' (10 20 30 40))
false
=> (set? ' (10 20 30 40))
false
=> (map? ' (10 20 30 40))
false
=> (vector? [10 20 30])
true
=> ([10 20 30] 0)
10
=> ({0 10 1 20 2 30 3 40}1)
20
=> ({0 10 1 20 2 30 3 40}0)
10
=> ({0 10 1 20 2 30 3 40}3)
40
=> ({0 10 1 20 2 30 3 40}4)
nil
=> ( #{ 10 20 30} 10 )
10
=> ( #{ 10 20 30} 20 )
20
=> ( #{ 10 20 30} 30 )
30
=> ( #{ 10 20 30} 40 )
nil
** por asociacion de un elmento al conjunto
=> (first '(10 20 30 40 50))
10
=> (rest '(10 20 30 40 50))
(20 30 40 50)
=> (rest '(20 30))
(30)
=> (rest [10 20 30])
(20 30)
=> (rest '(20 30))
(30)
=> (rest [10 20 30])
(20 30)
=> (first {10 20 30 40})
[10 20]
=> (rest {10 20 30 40})
([30 40])
=> (rest {10 20 30 40 50 60})
([30 40] [50 60])
=> (rest {50 60})
()
=> (first {})
nil
=> (first #{10 20 30})
20
=> (rest #{10 20 30})
(30 10)
=> (first #{ 30 10})
30
=> ((fn [x] (> (count x)3)) [10 20 30 40])
true
=> ((fn [x] (> (count x)3)) {:a 10 :b 20 :c 30})
false
=> (((fn [x] (fn [y] (+ (first x) (first y))) ) [30 20 10]) [50 60])
80
=> (((fn [x] (fn [y] [(first x) (first y)]) ) [30 20 10]) [50 60])
[30 50]
=> (((fn [x] (fn [y] [(rest x) (rest y)]) ) [30 20 10]) [50 60])
[(20 10) (60)]
=> ((fn [x y] (if (> (count x) (count y))x y))
[10 20 30 40 50]
[60 70 80 90]
)
[10 20 30 40 50]
=> ((fn [x y] (if (> (count x) (count y))x y))
[10 20 30 40 50]
[60 70 80 90 10 110]
)
[60 70 80 90 10 110]
=> ((fn [x] [x x x x x]) "hola")
["hola" "hola" "hola" "hola" "hola"]
=> ((fn [x] [x x x x x]) [10 20 30])
[[10 20 30]
[10 20 30]
[10 20 30]
[10 20 30]
[10 20 30]]
(defn f [x]
(* 2 x))
(defn vmap [f xs]
( letfn [ (recursividad [g g2 zs]
(if (empty? g2)
zs
(recursividad g
(rest g2)
(conj zs ( g (first g2))))
)
)] (recursividad f xs [] )))
(defn total-en [ xs]
(letfn [ (recursividad [ys ac]
(if (empty? ys )
ac
(recursividad (rest ys) (+ ac (first ys )))))]
(recursividad xs 0)))
(defn mmap [f xs]
(letfn [(recursividad [g g2 zs]
(if (empty? g2)
zs
(recursividad g
(rest g2)
(conj zs
[((first g2)0)
(g ( (first g2)1))]))))]
(recursividad f xs {})))
(defn filter [f xs]
(letfn [(recursividad [g ys zs]
(if (empty? ys)
zs
(recursividad g
(rest ys)
(if (g (first ys))
(conj zs (first ys)),zs))))]
(recursividad f xs [])))
(defn tiene-dos-elementos? [xs]
(== (count xs)2))
(defn tiene-dos-elementosV? [xs]
(and (vector? xs) (== (count xs)2)))
(defn rango [xs]
(or (and(>= xs 20) (<= xs 30)) (and (>= xs 40) (<= xs 50)))
)
(defn mfilter [f xs]
(letfn [(recursividad [g ys zs]
(if (empty? ys)
zs
(recursividad g
(rest ys)
(if (g (first ys)1)
(conj zs (first ys))
zs
))))]
(recursividad f xs {})))
(defn vreduce [f vi xs]
(letfn [(recursividad [g vf ys]
(if (empty? ys)
vf
(recursividad g
(g vf (first ys))
(rest ys))))]
(recursividad f vi xs)))
(defn vmap [f xs]
( letfn [ (recursividad [g g2 zs]
(if (empty? g2)
zs
(recursividad g
(rest g2)
(conj zs ( g (first g2))))
)
)] (recursividad f xs [] )))
(vmap (fn [x] (* 2 x)) [ 2 3 4])
[4 6 8]
(defn mmap [f zs]
(letfn [(recursividad [g g2 zs]
(if (empty? g2)
zs
(recursividad g
(rest g2)
(conj zs
[((first g2)0)
(g ( (first g2)1))])))]
=> (filter tiene-dos-elementos? [[10 20] [30] [40 50]])
[[10 20] [40 50]]
(defn filter [f xs]
(letfn [(recursividad [g ys zs]
(if (empty? ys)
zs
(recursividad g
(rest ys)
(if (g (first ys))
(conj zs (first ys)),zs))))]
(recursividad f xs [])))
(defn tiene-dos-elementos? [xs]
(== (count xs)2))
=> (filter tiene-dos-elementos? ["ho" "l" "a!"])
["ho" "a!"]
(defn tiene-dos-elementosV? [xs]
(and (vector? xs) (== (count xs)2)))
(filter tiene-dos-elementosV? [[10 20] 30 [40 50]])
[[10 20] [40 50]]
tiene-dos-elementosV?
(recursividad f xs {} )))
(defn rango [xs]
(or (and(>= xs 20) (<= xs 30)) (and (>= xs 40) (<= xs 50)))
)
(filter rango [10 15 25 40 30 27 42])
[25 40 30 27 42]
=> (filter (fn [xs]
(or (and(>= xs 20) (<= xs 30)) (and (>= xs 40) (<= xs 50)))
)[10 15 25 40 30 27 42])
[25 40 30 27 42]
=> (vreduce (fn [x y]
(+ x y))
0 [4 5 3])
12
=> (vreduce (fn [x y]
(* x y))
1 [4 5 3])
60
=> (vreduce (fn [x y]
(conj x [(count x)y]))
{} [10 20 30])
{0 10, 1 20, 2 30}
21 07 2016
(mmap (fn [x] (count x)) {:a [10 20] :b [30]})
{:a 2, :b 1}
=> (vmap (fn [x]
(mmap (fn [x] (* 3 x))x)) [ {:a 10 } {:a 10 :b 20} {}])
[{:a 30} {:a 30, :b 60} {}]
(defn cmap [f xs]
( letfn [ (recursividad [g g2 zs]
(if (empty? g2)
zs
(recursividad g
(rest g2)
(conj zs ( g (first g2))))
)
)] (recursividad f xs #{} )))
=> (cmap (fn [x] (* 2 x)) #{40 10 30})
#{20 60 80}
=> (vmap (fn [x]
(filter (fn [x] (and (even? x ) (>= x 0)))x))
[[2 3 4] [-2 -4 6] [10 -3 -5 12 -9 6]])
[[2 4] [6] [10 12 6]]
=> (mmap (fn [x] (if (>= x 0) x (* -1 x))) {:a -3 :b 5 :c -9})
{:a 3, :b 5, :c 9}
(defn cfilter [f xs]
(letfn [(recursividad [g ys zs]
(if (empty? ys)
zs
(recursividad g
(rest ys)
(if (g (first ys))
(conj zs (first ys)),zs))))]
(recursividad f xs #{})))
=> (cfilter (fn [x] (pos? x))#{10 -20 30})
#{30 10}
(defn smap [f xs]
(letfn [(recursividad [g ys zs]
(if (empty? ys)
zs
(recursividad g
(rest ys)
(str zs (g (first ys)))
)))]
(recursividad f xs "")))
(defn en-mayuscula [c] ({a A e E i I o O u U} c))
(defn en-mayusculas [c]
(let [mayusculas {a A e E i I o O u U} ]
(if (nil? (mayusculas c))
c
(mayusculas c))))
(smap en-mayuscula "aaaeee iiiooouuu")
AAAEEEIIIOOOUUU
=> (smap en-mayusculas "aa ee")
AA EE
(ns plf23072016.core
(:require [plf23072016.fos :as fos] :reload ))
(defn duplicados [xs]
(fos/vmap (fn [x] ( * 2 x)) xs))
(clojure.string /trim "hola"
(defn duplicados [xs]
(fos/vmap (fn [x] (* 2 x))xs))
(ns proyecto03.core
(:require [proyecto03.fos :as fos] :reload) )
(defn duplicados [xs]
(fos/vmap (fn [x] (* 2 x))xs))
(duplicados [2 3 4])
[4 6 8]
//
(defn composicion-de [f g]
(fn [x]
(g (f x))))
=> (fos/composicion-de (fn [x] (* 2 x)) (fn [x] (* 3 x)))
///////
(defn sfilter [f xs]
(letfn [(recursividad [g ys zs]
(if (empty? ys)
zs
(recursividad g
(rest ys)
(if (g (first ys))
(str zs (first ys))
zs ))))]
(recursividad f xs "" )))
//////////////
(sfilter (fn [x] (= x a)) "hola")
//////
(f "hola") ---> "Hola"
(f "hOLA")----> "Hola"
(f "hola mundo")---> "Hola Mundo"
/////
(defn vreduce [f vi xs]
(letfn [(recursividad [g vf ys]
(if (empty? ys)
vf
(recursividad g
(g vf (first ys))
(rest ys))))]
(recursividad f vi xs)))
(vreduce(fn [x y] :conj x [:count x) y])) {:a 10} {"hola" "mundo"])
__ (vreduce (fn [ x y ]
x)
{}
[2 -5 7-9 3 7])
---(let (mapa {:a 10 :b 10}]
(conj mapa { :a (+ 3 (mapa :a))]))
----{:a 13, :b 10}
(fn [x y]
(if (>= y 0)
(conj x [:positivos (inc (x :positivos))])
(conj x [:negativos (inc (x :negativos))]))) { :positivos 0 :negativos 0} -8)
=> (vreduce (fn [x y]
(if (>= y 0)
(conj x [:positivos (inc (x :positivos))])
(conj x [:negativos (inc (x :negativos))])))
{ :positivos 0 :negativos 0}
[2 -3 4 -5 6 7])
{:positivos 4, :negativos 2}
(sreduce (fn [x y]
(conj x y))
[]
(str 4567))
=> (let [x 10 y 20]
(+ x y))
30
=> (let [ a 10 b 20 c 30]
(* (+ a a) (+ b b) (+ c c))
)
48000
=> (let [x [ 10 20 30]
y [ 40 50 60]]
(+ (first x) (first y))
)
50
=> (let [x [10 20]
y [ 30 40]]
{:x x :y y})
{:x [10 20], :y [30 40]}
=> (let [x [50 60 70]
y (first x)] x)
[50 60 70]
=> (let [x [50 60 70]
y (first x)] y)
50
=> (let [x [ 50 60 70]
y [10 20 30]]
{:x x :y y :first-x (first x) :first-y (first y)})
{:x [50 60 70],
:y [10 20 30],
:first-x 50,
:first-y 10}
=> (let [a (+ 2 3)
b (* 2 3)
c (+ a b)]
{:a a :b b :c c})
{:a 5, :b 6, :c 11}
=> (let [x [ 50 60 70]
y [10 20 30]]
{:x x :y y :first-x (first x) :first-y (first y)})
{:x [50 60 70],
:y [10 20 30],
:first-x 50,
:first-y 10}
=> (let [a true b true c true]
(and a b c))
true
=> ((fn [x]
(let [a 10 b 20 x 30]
(+ a b x)))24)
60
=> ((fn [x]
(let [a 10 b 20 c 30]
(+ a b x)))24)
54
=> (if false
(let [x 10]
(* 2 x))
(let [x 20]
(* 5 x)))
100
((fn [x]
(if (>= x 0)
(let [ y 1]
(* y x))
(let [y -1]
(* y x))))
-65)
65
=> (let [x -4]
(if (>= x 10)
(let [y (* x x)]
y)
(let [ y ( + x x)]
y)))
-8
(let [f (fn [x] (* 2 x))
g (fn [x] (* 3 x))]
(f ( g 5)))
30
//aplicar a f con el resultado de g de 5
=> (let [f (fn [x] (* 2 x))
g (fn [x] (* 3 x))
h (f (g 7))]
h)
42
=> (let [f (fn [x] (* 2 x))
g (fn [x] (* 3 x))
h (f (g 7))
i (fn [x] {:resultado-final x})]
(i h) )
{:resultado-final 42}
recursividad---
=> ((fn [x]
(letfn [ (g [ ei ef i a ]
(if (> i ef)
a
(g ei ef (inc i) (+ a i))))]
(g 0 x 0 0))) 5)
15
=> ((fn [x y]
(letfn [ (g [ ei ef i a ]
(if (> i ef)
a
(g ei ef (inc i) (+ a i))))]
(g x y x x))) 0 5)
15
=> ((fn [n] ((fn [x y]
(letfn [ (g [ ei ef i a ]
(if (> i ef)
a
(g ei ef (inc i) (+ a i))))]
(g x y x x))) 0 n)) 5)
15
=> ((fn [x y]
(letfn [ (g [ ei ef c a ]
(if (== ei ef)
a
(g (inc ei) ef c(+ a c))))]
(g 0 x y 0))) 5 20)
100
=> (rest [ 10 20 30])
(20 30)
=> (rest (rest [10 20 30]))
(30)
=> (first ( rest ( rest [10 20 30])))
30
=> (+ (firsst [10 20 30])
(first (rest [10 20 30]))
(first (rest (rest [10 20 30]))))
CompilerException java.lang.RuntimeException: Unable to resolve symbol: firsst in this context,
compiling:(C:UsersxenosAppDataLocalTempform-init7869937070705144292.clj:1:4)
=> (+ (first [10 20 30])
(first (rest [10 20 30]))
(first (rest (rest [10 20 30]))))
60
=> (let [x 10 y 20]
(+ x y))
30
=> (let [ a 10 b 20 c 30]
(* (+ a a) (+ b b) (+ c c))
)
48000
=> (let [x [ 10 20 30]
y [ 40 50 60]]
(+ (first x) (first y))
)
50
=> (let [x [10 20]
y [ 30 40]]
{:x x :y y})
{:x [10 20], :y [30 40]}
=> (let [x [50 60 70]
y (first x)] x)
[50 60 70]
=> (let [x [50 60 70]
y (first x)] y)
50
=> (let [x [ 50 60 70]
y [10 20 30]]
{:x x :y y :first-x (first x) :first-y (first y)})
{:x [50 60 70],
:y [10 20 30],
:first-x 50,
:first-y 10}
=> (let [a (+ 2 3)
b (* 2 3)
c (+ a b)]
{:a a :b b :c c})
{:a 5, :b 6, :c 11}
=> (let [x [ 50 60 70]
y [10 20 30]]
{:x x :y y :first-x (first x) :first-y (first y)})
{:x [50 60 70],
:y [10 20 30],
:first-x 50,
:first-y 10}
=> (let [a true b true c true]
(and a b c))
true
=> ((fn [x]
(let [a 10 b 20 x 30]
(+ a b x)))24)
60
=> ((fn [x]
(let [a 10 b 20 c 30]
(+ a b x)))24)
54
=> (if false
(let [x 10]
(* 2 x))
(let [x 20]
(* 5 x)))
100
((fn [x]
(if (>= x 0)
(let [ y 1]
(* y x))
(let [y -1]
(* y x))))
-65)
65
=> (let [x -4]
(if (>= x 10)
(let [y (* x x)]
y)
(let [ y ( + x x)]
y)))
-8
(let [f (fn [x] (* 2 x))
g (fn [x] (* 3 x))]
(f ( g 5)))
30
//aplicar a f con el resultado de g de 5
=> (let [f (fn [x] (* 2 x))
g (fn [x] (* 3 x))
h (f (g 7))]
h)
42
=> (let [f (fn [x] (* 2 x))
g (fn [x] (* 3 x))
h (f (g 7))
i (fn [x] {:resultado-final x})]
(i h) )
{:resultado-final 42}
recursividad---
=> ((fn [x]
(letfn [ (g [ ei ef i a ]
(if (> i ef)
a
(g ei ef (inc i) (+ a i))))]
(g 0 x 0 0))) 5)
15
=> ((fn [x y]
(letfn [ (g [ ei ef i a ]
(if (> i ef)
a
(g ei ef (inc i) (+ a i))))]
(g x y x x))) 0 5)
15
=> ((fn [n] ((fn [x y]
(letfn [ (g [ ei ef i a ]
(if (> i ef)
a
(g ei ef (inc i) (+ a i))))]
(g x y x x))) 0 n)) 5)
15
=> ((fn [x y]
(letfn [ (g [ ei ef c a ]
(if (== ei ef)
a
(g (inc ei) ef c(+ a c))))]
(g 0 x y 0))) 5 20)
100
=> (rest [ 10 20 30])
(20 30)
=> (rest (rest [10 20 30]))
(30)
=> (first ( rest ( rest [10 20 30])))
30
=> (+ (firsst [10 20 30])
(first (rest [10 20 30]))
(first (rest (rest [10 20 30]))))
CompilerException java.lang.RuntimeException: Unable to resolve symbol: firsst in this context,
compiling:(C:UsersxenosAppDataLocalTempform-init7869937070705144292.clj:1:4)
=> (+ (first [10 20 30])
(first (rest [10 20 30]))
(first (rest (rest [10 20 30]))))
60
(ns plf23072016.core
(:require [plf23072016.fos :as fos] :reload ))
(defn duplicados [xs]
(fos/vmap (fn [x] ( * 2 x)) xs))
(clojure.string /trim "hola"
=> '("" "" "" "")
("" "" "" "")
=> '("" "" "" "")
("" "" "" "")
=> ["hola" true true 4.9 3/2]
["hola" true true 4.9 3/2]
=> [a e i "o" "u"]
[a e i "o" "u"]
=> {10 20 20 20 30 20 40 20}
{10 20, 20 20, 30 20, 40 20}
=> (true false false true
)
ClassCastException java.lang.Boolean cannot be cast to clojure.lang.IFn
proyecto03.core/eval8026 (form-init6206876087026402955.clj:1)
=> (true false false true)
ClassCastException java.lang.Boolean cannot be cast to clojure.lang.IFn
proyecto03.core/eval8028 (form-init6206876087026402955.clj:1)
=> { true false false true}
{true false, false true}
=> #{true false}
#{true false}
=> # {true false true}
RuntimeException Map literal must contain an even number of forms
clojure.lang.Util.runtimeException (Util.java:221)
=> (count ' (10 20 30 40))
4
=> (empty? ' (10 20 30 40))
false
=> (list? ' (10 20 30 40))
true
=> (vector? ' (10 20 30 40))
false
=> (set? ' (10 20 30 40))
false
=> (map? ' (10 20 30 40))
false
=> (vector? [10 20 30])
true
=> ([10 20 30] 0)
10
=> ({0 10 1 20 2 30 3 40}1)
20
=> ({0 10 1 20 2 30 3 40}0)
10
=> ({0 10 1 20 2 30 3 40}3)
40
=> ({0 10 1 20 2 30 3 40}4)
nil
=> ( #{ 10 20 30} 10 )
10
=> ( #{ 10 20 30} 20 )
20
=> ( #{ 10 20 30} 30 )
30
=> ( #{ 10 20 30} 40 )
nil
** por asociacion de un elmento al conjunto
=> (first '(10 20 30 40 50))
10
=> (rest '(10 20 30 40 50))
(20 30 40 50)
=> (rest '(20 30))
(30)
=> (rest [10 20 30])
(20 30)
=> (rest '(20 30))
(30)
=> (rest [10 20 30])
(20 30)
=> (first {10 20 30 40})
[10 20]
=> (rest {10 20 30 40})
([30 40])
=> (rest {10 20 30 40 50 60})
([30 40] [50 60])
=> (rest {50 60})
()
=> (first {})
nil
=> (first #{10 20 30})
20
=> (rest #{10 20 30})
(30 10)
=> (first #{ 30 10})
30
=> ((fn [x] (> (count x)3)) [10 20 30 40])
true
=> ((fn [x] (> (count x)3)) {:a 10 :b 20 :c 30})
false
=> (((fn [x] (fn [y] (+ (first x) (first y))) ) [30 20 10]) [50 60])
80
=> (((fn [x] (fn [y] [(first x) (first y)]) ) [30 20 10]) [50 60])
[30 50]
=> (((fn [x] (fn [y] [(rest x) (rest y)]) ) [30 20 10]) [50 60])
[(20 10) (60)]
=> ((fn [x y] (if (> (count x) (count y))x y))
[10 20 30 40 50]
[60 70 80 90]
)
[10 20 30 40 50]
=> ((fn [x y] (if (> (count x) (count y))x y))
[10 20 30 40 50]
[60 70 80 90 10 110]
)
[60 70 80 90 10 110]
=> ((fn [x] [x x x x x]) "hola")
["hola" "hola" "hola" "hola" "hola"]
=> ((fn [x] [x x x x x]) [10 20 30])
[[10 20 30]
[10 20 30]
[10 20 30]
[10 20 30]
[10 20 30]]
((fn [x] {(x 0) (x 1)}) [10 20])
{10 20}
=> (rest { :a 10 :b 20})
([:b 20])
=> ((fn [ x y] { x (* 4 x) y (* 4 y)})10 20)
{10 40, 20 80}
=> ((fn [x] {(first x) x}) [50 20 40])
{50 [50 20 40]}
=> ((fn [x] {:anterior (dec x) :siguiente (inc x)})45)
{:anterior 44, :siguiente 46}
=> ((fn [ x y z] #{x y z})10 20 30)
#{20 30 10}
=> ((fn [x y] [{:x y} {:y x}])40 50)
[{:x 50} {:y 40}]
(fn [nombre apellido-paterno apellido-materno])
=> ((fn [nombre apellido-paterno apellido-materno]
{:nombre nombre :apellido
{ :paterno apellido-paterno :materno apellido-materno}}
) "Joaquin" "Martinez" "Benjamin")
{:nombre "Joaquin",
:apellido
{:paterno "Martinez",
:materno "Benjamin"}}
=> #{[10 20] [30 40] [20 10]}
#{[20 10] [10 20] [30 40]}
=> '("" "" "" "")
("" "" "" "")
=> '("" "" "" "")
("" "" "" "")
=> ["hola" true true 4.9 3/2]
["hola" true true 4.9 3/2]
=> [a e i "o" "u"]
[a e i "o" "u"]
=> {10 20 20 20 30 20 40 20}
{10 20, 20 20, 30 20, 40 20}
=> (true false false true
)
ClassCastException java.lang.Boolean cannot be cast to clojure.lang.IFn
proyecto03.core/eval8026 (form-init6206876087026402955.clj:1)
=> (true false false true)
ClassCastException java.lang.Boolean cannot be cast to clojure.lang.IFn
proyecto03.core/eval8028 (form-init6206876087026402955.clj:1)
=> { true false false true}
{true false, false true}
=> #{true false}
#{true false}
=> # {true false true}
RuntimeException Map literal must contain an even number of forms
clojure.lang.Util.runtimeException (Util.java:221)
=> (count ' (10 20 30 40))
4
=> (empty? ' (10 20 30 40))
false
=> (list? ' (10 20 30 40))
true
=> (vector? ' (10 20 30 40))
false
=> (set? ' (10 20 30 40))
false
=> (map? ' (10 20 30 40))
false
=> (vector? [10 20 30])
true
=> ([10 20 30] 0)
10
=> ({0 10 1 20 2 30 3 40}1)
20
=> ({0 10 1 20 2 30 3 40}0)
10
=> ({0 10 1 20 2 30 3 40}3)
40
=> ({0 10 1 20 2 30 3 40}4)
nil
=> ( #{ 10 20 30} 10 )
10
=> ( #{ 10 20 30} 20 )
20
=> ( #{ 10 20 30} 30 )
30
=> ( #{ 10 20 30} 40 )
nil
** por asociacion de un elmento al conjunto
=> (first '(10 20 30 40 50))
10
=> (rest '(10 20 30 40 50))
(20 30 40 50)
=> (rest '(20 30))
(30)
=> (rest [10 20 30])
(20 30)
=> (rest '(20 30))
(30)
=> (rest [10 20 30])
(20 30)
=> (first {10 20 30 40})
[10 20]
=> (rest {10 20 30 40})
([30 40])
=> (rest {10 20 30 40 50 60})
([30 40] [50 60])
=> (rest {50 60})
()
=> (first {})
nil
=> (first #{10 20 30})
20
=> (rest #{10 20 30})
(30 10)
=> (first #{ 30 10})
30
=> ((fn [x] (> (count x)3)) [10 20 30 40])
true
=> ((fn [x] (> (count x)3)) {:a 10 :b 20 :c 30})
false
=> (((fn [x] (fn [y] (+ (first x) (first y))) ) [30 20 10]) [50 60])
80
=> (((fn [x] (fn [y] [(first x) (first y)]) ) [30 20 10]) [50 60])
[30 50]
=> (((fn [x] (fn [y] [(rest x) (rest y)]) ) [30 20 10]) [50 60])
[(20 10) (60)]
=> ((fn [x y] (if (> (count x) (count y))x y))
[10 20 30 40 50]
[60 70 80 90]
)
[10 20 30 40 50]
=> ((fn [x y] (if (> (count x) (count y))x y))
[10 20 30 40 50]
[60 70 80 90 10 110]
)
[60 70 80 90 10 110]
=> ((fn [x] [x x x x x]) "hola")
["hola" "hola" "hola" "hola" "hola"]
=> ((fn [x] [x x x x x]) [10 20 30])
[[10 20 30]
[10 20 30]
[10 20 30]
[10 20 30]
[10 20 30]]
((fn [x] {(x 0) (x 1)}) [10 20])
{10 20}
=> (rest { :a 10 :b 20})
([:b 20])
=> ((fn [ x y] { x (* 4 x) y (* 4 y)})10 20)
{10 40, 20 80}
=> ((fn [x] {(first x) x}) [50 20 40])
{50 [50 20 40]}
=> ((fn [x] {:anterior (dec x) :siguiente (inc x)})45)
{:anterior 44, :siguiente 46}
=> ((fn [ x y z] #{x y z})10 20 30)
#{20 30 10}
=> ((fn [x y] [{:x y} {:y x}])40 50)
[{:x 50} {:y 40}]
(fn [nombre apellido-paterno apellido-materno])
=> ((fn [nombre apellido-paterno apellido-materno]
{:nombre nombre :apellido
{ :paterno apellido-paterno :materno apellido-materno}}
) "Joaquin" "Martinez" "Benjamin")
{:nombre "Joaquin",
:apellido
{:paterno "Martinez",
:materno "Benjamin"}}
=> #{[10 20] [30 40] [20 10]}
#{[20 10] [10 20] [30 40]}
Apuntes clojure
Apuntes clojure
Apuntes clojure
Apuntes clojure

More Related Content

What's hot

Beyond Scala Lens
Beyond Scala LensBeyond Scala Lens
Beyond Scala Lens
Julien Truffaut
 
The Ring programming language version 1.5.2 book - Part 35 of 181
The Ring programming language version 1.5.2 book - Part 35 of 181The Ring programming language version 1.5.2 book - Part 35 of 181
The Ring programming language version 1.5.2 book - Part 35 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 36 of 185
The Ring programming language version 1.5.4 book - Part 36 of 185The Ring programming language version 1.5.4 book - Part 36 of 185
The Ring programming language version 1.5.4 book - Part 36 of 185
Mahmoud Samir Fayed
 
3 capitulo-iii-matriz-asociada-sem-15-t-l-e
3 capitulo-iii-matriz-asociada-sem-15-t-l-e3 capitulo-iii-matriz-asociada-sem-15-t-l-e
3 capitulo-iii-matriz-asociada-sem-15-t-l-e
FernandoDanielMamani1
 
Turunan Fungsi Aljabar
Turunan Fungsi AljabarTurunan Fungsi Aljabar
Turunan Fungsi Aljabar
EnidaMartianaSari
 
ตัวอย่างข้อสอบเก่า วิชาคณิตศาสตร์ ม.6 ปีการศึกษา 2553
ตัวอย่างข้อสอบเก่า วิชาคณิตศาสตร์ ม.6 ปีการศึกษา 2553ตัวอย่างข้อสอบเก่า วิชาคณิตศาสตร์ ม.6 ปีการศึกษา 2553
ตัวอย่างข้อสอบเก่า วิชาคณิตศาสตร์ ม.6 ปีการศึกษา 2553
Destiny Nooppynuchy
 
Tugas blog-matematika
Tugas blog-matematikaTugas blog-matematika
Tugas blog-matematika
Ari Bahri Lubis
 
The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180
Mahmoud Samir Fayed
 
ゲーム理論BASIC 第38回 -続・カーネル-
ゲーム理論BASIC 第38回 -続・カーネル-ゲーム理論BASIC 第38回 -続・カーネル-
ゲーム理論BASIC 第38回 -続・カーネル-
ssusere0a682
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scala
Siarhiej Siemianchuk
 
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm ProblemsLeet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
Sunil Yadav
 
S1 3 derivadas_resueltas
S1 3 derivadas_resueltasS1 3 derivadas_resueltas
S1 3 derivadas_resueltas
jesquerrev1
 
Appendex
AppendexAppendex
Appendex
swavicky
 
LeetCode April Coding Challenge
LeetCode April Coding ChallengeLeetCode April Coding Challenge
LeetCode April Coding Challenge
Sunil Yadav
 
近似ベイズ計算によるベイズ推定
近似ベイズ計算によるベイズ推定近似ベイズ計算によるベイズ推定
近似ベイズ計算によるベイズ推定
Kosei ABE
 
Program Language - Fall 2013
Program Language - Fall 2013 Program Language - Fall 2013
Program Language - Fall 2013
Yun-Yan Chi
 
Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...
Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...
Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...
The1 Uploader
 
Algebra 2 Section 5-1
Algebra 2 Section 5-1Algebra 2 Section 5-1
Algebra 2 Section 5-1
Jimbo Lamb
 
Optics with monocle - Modeling the part and the whole
Optics with monocle - Modeling the part and the wholeOptics with monocle - Modeling the part and the whole
Optics with monocle - Modeling the part and the whole
Ilan Godik
 

What's hot (19)

Beyond Scala Lens
Beyond Scala LensBeyond Scala Lens
Beyond Scala Lens
 
The Ring programming language version 1.5.2 book - Part 35 of 181
The Ring programming language version 1.5.2 book - Part 35 of 181The Ring programming language version 1.5.2 book - Part 35 of 181
The Ring programming language version 1.5.2 book - Part 35 of 181
 
The Ring programming language version 1.5.4 book - Part 36 of 185
The Ring programming language version 1.5.4 book - Part 36 of 185The Ring programming language version 1.5.4 book - Part 36 of 185
The Ring programming language version 1.5.4 book - Part 36 of 185
 
3 capitulo-iii-matriz-asociada-sem-15-t-l-e
3 capitulo-iii-matriz-asociada-sem-15-t-l-e3 capitulo-iii-matriz-asociada-sem-15-t-l-e
3 capitulo-iii-matriz-asociada-sem-15-t-l-e
 
Turunan Fungsi Aljabar
Turunan Fungsi AljabarTurunan Fungsi Aljabar
Turunan Fungsi Aljabar
 
ตัวอย่างข้อสอบเก่า วิชาคณิตศาสตร์ ม.6 ปีการศึกษา 2553
ตัวอย่างข้อสอบเก่า วิชาคณิตศาสตร์ ม.6 ปีการศึกษา 2553ตัวอย่างข้อสอบเก่า วิชาคณิตศาสตร์ ม.6 ปีการศึกษา 2553
ตัวอย่างข้อสอบเก่า วิชาคณิตศาสตร์ ม.6 ปีการศึกษา 2553
 
Tugas blog-matematika
Tugas blog-matematikaTugas blog-matematika
Tugas blog-matematika
 
The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180
 
ゲーム理論BASIC 第38回 -続・カーネル-
ゲーム理論BASIC 第38回 -続・カーネル-ゲーム理論BASIC 第38回 -続・カーネル-
ゲーム理論BASIC 第38回 -続・カーネル-
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scala
 
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm ProblemsLeet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
 
S1 3 derivadas_resueltas
S1 3 derivadas_resueltasS1 3 derivadas_resueltas
S1 3 derivadas_resueltas
 
Appendex
AppendexAppendex
Appendex
 
LeetCode April Coding Challenge
LeetCode April Coding ChallengeLeetCode April Coding Challenge
LeetCode April Coding Challenge
 
近似ベイズ計算によるベイズ推定
近似ベイズ計算によるベイズ推定近似ベイズ計算によるベイズ推定
近似ベイズ計算によるベイズ推定
 
Program Language - Fall 2013
Program Language - Fall 2013 Program Language - Fall 2013
Program Language - Fall 2013
 
Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...
Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...
Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...
 
Algebra 2 Section 5-1
Algebra 2 Section 5-1Algebra 2 Section 5-1
Algebra 2 Section 5-1
 
Optics with monocle - Modeling the part and the whole
Optics with monocle - Modeling the part and the wholeOptics with monocle - Modeling the part and the whole
Optics with monocle - Modeling the part and the whole
 

Similar to Apuntes clojure

Tugasmatematikakelompok
TugasmatematikakelompokTugasmatematikakelompok
Tugasmatematikakelompok
gundul28
 
Tugas matematika kelompok
Tugas matematika kelompokTugas matematika kelompok
Tugas matematika kelompok
achmadtrybuana
 
Re:ゲーム理論入門 第14回 - 仁 -
Re:ゲーム理論入門 第14回 - 仁 -Re:ゲーム理論入門 第14回 - 仁 -
Re:ゲーム理論入門 第14回 - 仁 -
ssusere0a682
 
Tugasmatematikakelompok 150715235527-lva1-app6892
Tugasmatematikakelompok 150715235527-lva1-app6892Tugasmatematikakelompok 150715235527-lva1-app6892
Tugasmatematikakelompok 150715235527-lva1-app6892
drayertaurus
 
Hitchhiker's Guide to Functional Programming
Hitchhiker's Guide to Functional ProgrammingHitchhiker's Guide to Functional Programming
Hitchhiker's Guide to Functional Programming
Sergey Shishkin
 
Basic m4-2-chapter1
Basic m4-2-chapter1Basic m4-2-chapter1
Millionways
MillionwaysMillionways
Millionways
Brian Lonsdorf
 
Interpolation functions
Interpolation functionsInterpolation functions
Interpolation functions
Tarun Gehlot
 
数式処理ソフトMathematicaで数学の問題を解く
数式処理ソフトMathematicaで数学の問題を解く数式処理ソフトMathematicaで数学の問題を解く
数式処理ソフトMathematicaで数学の問題を解く
Yoshihiro Mizoguchi
 
Lambda calculus
Lambda calculusLambda calculus
Lambda calculus
Attila Magyar
 
jhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfg
jhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfgjhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfg
jhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfg
Tonn Za
 
chap 2 Ex#1.1
chap 2 Ex#1.1chap 2 Ex#1.1
chap 2 Ex#1.1
Ans Ali
 
CRL 1.8 Functions
CRL 1.8 FunctionsCRL 1.8 Functions
CRL 1.8 Functions
A Jorge Garcia
 
Table of Useful R commands.
Table of Useful R commands.Table of Useful R commands.
Table of Useful R commands.
Dr. Volkan OBAN
 
Single page-integral-table
Single page-integral-tableSingle page-integral-table
Single page-integral-table
Monique Anderson
 
DSP_FOEHU - Lec 04 - Discrete-Time Signals and Systems
DSP_FOEHU - Lec 04 - Discrete-Time Signals and SystemsDSP_FOEHU - Lec 04 - Discrete-Time Signals and Systems
DSP_FOEHU - Lec 04 - Discrete-Time Signals and Systems
Amr E. Mohamed
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
ikdysfm
 
Interpolation
InterpolationInterpolation
Interpolation
Brijesh Padhiyar
 
Integral table
Integral tableIntegral table
Integral table
Ankitcos0
 
Oh Composable World!
Oh Composable World!Oh Composable World!
Oh Composable World!
Brian Lonsdorf
 

Similar to Apuntes clojure (20)

Tugasmatematikakelompok
TugasmatematikakelompokTugasmatematikakelompok
Tugasmatematikakelompok
 
Tugas matematika kelompok
Tugas matematika kelompokTugas matematika kelompok
Tugas matematika kelompok
 
Re:ゲーム理論入門 第14回 - 仁 -
Re:ゲーム理論入門 第14回 - 仁 -Re:ゲーム理論入門 第14回 - 仁 -
Re:ゲーム理論入門 第14回 - 仁 -
 
Tugasmatematikakelompok 150715235527-lva1-app6892
Tugasmatematikakelompok 150715235527-lva1-app6892Tugasmatematikakelompok 150715235527-lva1-app6892
Tugasmatematikakelompok 150715235527-lva1-app6892
 
Hitchhiker's Guide to Functional Programming
Hitchhiker's Guide to Functional ProgrammingHitchhiker's Guide to Functional Programming
Hitchhiker's Guide to Functional Programming
 
Basic m4-2-chapter1
Basic m4-2-chapter1Basic m4-2-chapter1
Basic m4-2-chapter1
 
Millionways
MillionwaysMillionways
Millionways
 
Interpolation functions
Interpolation functionsInterpolation functions
Interpolation functions
 
数式処理ソフトMathematicaで数学の問題を解く
数式処理ソフトMathematicaで数学の問題を解く数式処理ソフトMathematicaで数学の問題を解く
数式処理ソフトMathematicaで数学の問題を解く
 
Lambda calculus
Lambda calculusLambda calculus
Lambda calculus
 
jhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfg
jhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfgjhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfg
jhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfg
 
chap 2 Ex#1.1
chap 2 Ex#1.1chap 2 Ex#1.1
chap 2 Ex#1.1
 
CRL 1.8 Functions
CRL 1.8 FunctionsCRL 1.8 Functions
CRL 1.8 Functions
 
Table of Useful R commands.
Table of Useful R commands.Table of Useful R commands.
Table of Useful R commands.
 
Single page-integral-table
Single page-integral-tableSingle page-integral-table
Single page-integral-table
 
DSP_FOEHU - Lec 04 - Discrete-Time Signals and Systems
DSP_FOEHU - Lec 04 - Discrete-Time Signals and SystemsDSP_FOEHU - Lec 04 - Discrete-Time Signals and Systems
DSP_FOEHU - Lec 04 - Discrete-Time Signals and Systems
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
 
Interpolation
InterpolationInterpolation
Interpolation
 
Integral table
Integral tableIntegral table
Integral table
 
Oh Composable World!
Oh Composable World!Oh Composable World!
Oh Composable World!
 

More from Benjamín Joaquín Martínez

Sistemas de detección de intrusiones.pdf
Sistemas de detección de intrusiones.pdfSistemas de detección de intrusiones.pdf
Sistemas de detección de intrusiones.pdf
Benjamín Joaquín Martínez
 
Portafolio ingles.pdf
Portafolio ingles.pdfPortafolio ingles.pdf
Portafolio ingles.pdf
Benjamín Joaquín Martínez
 
Tabla de llamadas para linux x86_64 bits.pdf
Tabla de llamadas para linux x86_64 bits.pdfTabla de llamadas para linux x86_64 bits.pdf
Tabla de llamadas para linux x86_64 bits.pdf
Benjamín Joaquín Martínez
 
Sistema de registro con php
Sistema de registro con phpSistema de registro con php
Sistema de registro con php
Benjamín Joaquín Martínez
 
compiladores6Benjamin133467.pdf
compiladores6Benjamin133467.pdfcompiladores6Benjamin133467.pdf
compiladores6Benjamin133467.pdf
Benjamín Joaquín Martínez
 
Compiladores5_Benjamin133467.pdf
Compiladores5_Benjamin133467.pdfCompiladores5_Benjamin133467.pdf
Compiladores5_Benjamin133467.pdf
Benjamín Joaquín Martínez
 
133467 compiladores 4.pdf
133467 compiladores 4.pdf133467 compiladores 4.pdf
133467 compiladores 4.pdf
Benjamín Joaquín Martínez
 
133467_COMPILADORES3.pdf
133467_COMPILADORES3.pdf133467_COMPILADORES3.pdf
133467_COMPILADORES3.pdf
Benjamín Joaquín Martínez
 
133467_COMPILADORES2
133467_COMPILADORES2133467_COMPILADORES2
133467_COMPILADORES2
Benjamín Joaquín Martínez
 
COMPILADORES1.pdf
COMPILADORES1.pdfCOMPILADORES1.pdf
COMPILADORES1.pdf
Benjamín Joaquín Martínez
 
Algoritmos de búsqueda.pdf
Algoritmos de búsqueda.pdfAlgoritmos de búsqueda.pdf
Algoritmos de búsqueda.pdf
Benjamín Joaquín Martínez
 
Logica proposicional
Logica proposicionalLogica proposicional
Logica proposicional
Benjamín Joaquín Martínez
 
Lenguajes para dispositivos moviles 133467
Lenguajes para dispositivos moviles 133467Lenguajes para dispositivos moviles 133467
Lenguajes para dispositivos moviles 133467
Benjamín Joaquín Martínez
 
Bd distribuidas
Bd distribuidasBd distribuidas
diseño de bases de datos distribuidas
diseño de bases de datos distribuidas   diseño de bases de datos distribuidas
diseño de bases de datos distribuidas
Benjamín Joaquín Martínez
 
procesamiento de consultas distribuidas
procesamiento de consultas distribuidasprocesamiento de consultas distribuidas
procesamiento de consultas distribuidas
Benjamín Joaquín Martínez
 
Algoritmo de INGRES
Algoritmo de INGRES Algoritmo de INGRES
Algoritmo de INGRES
Benjamín Joaquín Martínez
 
Fragmentación
FragmentaciónFragmentación
Modelo cliente servidor
Modelo cliente servidorModelo cliente servidor
Modelo cliente servidor
Benjamín Joaquín Martínez
 
Arquitectura de bases de datos distribuidas
Arquitectura de bases de datos distribuidasArquitectura de bases de datos distribuidas
Arquitectura de bases de datos distribuidas
Benjamín Joaquín Martínez
 

More from Benjamín Joaquín Martínez (20)

Sistemas de detección de intrusiones.pdf
Sistemas de detección de intrusiones.pdfSistemas de detección de intrusiones.pdf
Sistemas de detección de intrusiones.pdf
 
Portafolio ingles.pdf
Portafolio ingles.pdfPortafolio ingles.pdf
Portafolio ingles.pdf
 
Tabla de llamadas para linux x86_64 bits.pdf
Tabla de llamadas para linux x86_64 bits.pdfTabla de llamadas para linux x86_64 bits.pdf
Tabla de llamadas para linux x86_64 bits.pdf
 
Sistema de registro con php
Sistema de registro con phpSistema de registro con php
Sistema de registro con php
 
compiladores6Benjamin133467.pdf
compiladores6Benjamin133467.pdfcompiladores6Benjamin133467.pdf
compiladores6Benjamin133467.pdf
 
Compiladores5_Benjamin133467.pdf
Compiladores5_Benjamin133467.pdfCompiladores5_Benjamin133467.pdf
Compiladores5_Benjamin133467.pdf
 
133467 compiladores 4.pdf
133467 compiladores 4.pdf133467 compiladores 4.pdf
133467 compiladores 4.pdf
 
133467_COMPILADORES3.pdf
133467_COMPILADORES3.pdf133467_COMPILADORES3.pdf
133467_COMPILADORES3.pdf
 
133467_COMPILADORES2
133467_COMPILADORES2133467_COMPILADORES2
133467_COMPILADORES2
 
COMPILADORES1.pdf
COMPILADORES1.pdfCOMPILADORES1.pdf
COMPILADORES1.pdf
 
Algoritmos de búsqueda.pdf
Algoritmos de búsqueda.pdfAlgoritmos de búsqueda.pdf
Algoritmos de búsqueda.pdf
 
Logica proposicional
Logica proposicionalLogica proposicional
Logica proposicional
 
Lenguajes para dispositivos moviles 133467
Lenguajes para dispositivos moviles 133467Lenguajes para dispositivos moviles 133467
Lenguajes para dispositivos moviles 133467
 
Bd distribuidas
Bd distribuidasBd distribuidas
Bd distribuidas
 
diseño de bases de datos distribuidas
diseño de bases de datos distribuidas   diseño de bases de datos distribuidas
diseño de bases de datos distribuidas
 
procesamiento de consultas distribuidas
procesamiento de consultas distribuidasprocesamiento de consultas distribuidas
procesamiento de consultas distribuidas
 
Algoritmo de INGRES
Algoritmo de INGRES Algoritmo de INGRES
Algoritmo de INGRES
 
Fragmentación
FragmentaciónFragmentación
Fragmentación
 
Modelo cliente servidor
Modelo cliente servidorModelo cliente servidor
Modelo cliente servidor
 
Arquitectura de bases de datos distribuidas
Arquitectura de bases de datos distribuidasArquitectura de bases de datos distribuidas
Arquitectura de bases de datos distribuidas
 

Recently uploaded

2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
YousufSait3
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Envertis Software Solutions
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
sjcobrien
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
Ayan Halder
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
Rakesh Kumar R
 

Recently uploaded (20)

2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
 

Apuntes clojure

  • 1. (defn f [x] (* 2 x)) (defn vmap [f xs] ( letfn [ (recursividad [g g2 zs] (if (empty? g2) zs (recursividad g (rest g2) (conj zs ( g (first g2)))) ) )] (recursividad f xs [] ))) (defn total-en [ xs] (letfn [ (recursividad [ys ac] (if (empty? ys ) ac (recursividad (rest ys) (+ ac (first ys )))))] (recursividad xs 0))) (defn mmap [f xs] (letfn [(recursividad [g g2 zs] (if (empty? g2) zs (recursividad g (rest g2) (conj zs [((first g2)0) (g ( (first g2)1))]))))] (recursividad f xs {}))) (defn filter [f xs] (letfn [(recursividad [g ys zs] (if (empty? ys) zs (recursividad g (rest ys) (if (g (first ys)) (conj zs (first ys)),zs))))] (recursividad f xs [])))
  • 2. (defn tiene-dos-elementos? [xs] (== (count xs)2)) (defn tiene-dos-elementosV? [xs] (and (vector? xs) (== (count xs)2))) (defn rango [xs] (or (and(>= xs 20) (<= xs 30)) (and (>= xs 40) (<= xs 50))) ) (defn mfilter [f xs] (letfn [(recursividad [g ys zs] (if (empty? ys) zs (recursividad g (rest ys) (if (g (first ys)1) (conj zs (first ys)) zs ))))] (recursividad f xs {}))) (defn vreduce [f vi xs] (letfn [(recursividad [g vf ys] (if (empty? ys) vf (recursividad g (g vf (first ys)) (rest ys))))] (recursividad f vi xs))) (defn vmap [f xs] ( letfn [ (recursividad [g g2 zs] (if (empty? g2) zs (recursividad g (rest g2) (conj zs ( g (first g2)))) ) )] (recursividad f xs [] )))
  • 3. (vmap (fn [x] (* 2 x)) [ 2 3 4]) [4 6 8] (defn mmap [f zs] (letfn [(recursividad [g g2 zs] (if (empty? g2) zs (recursividad g (rest g2) (conj zs [((first g2)0) (g ( (first g2)1))])))] => (filter tiene-dos-elementos? [[10 20] [30] [40 50]]) [[10 20] [40 50]] (defn filter [f xs] (letfn [(recursividad [g ys zs] (if (empty? ys) zs (recursividad g (rest ys) (if (g (first ys)) (conj zs (first ys)),zs))))] (recursividad f xs []))) (defn tiene-dos-elementos? [xs] (== (count xs)2)) => (filter tiene-dos-elementos? ["ho" "l" "a!"]) ["ho" "a!"] (defn tiene-dos-elementosV? [xs] (and (vector? xs) (== (count xs)2))) (filter tiene-dos-elementosV? [[10 20] 30 [40 50]]) [[10 20] [40 50]] tiene-dos-elementosV?
  • 4. (recursividad f xs {} ))) (defn rango [xs] (or (and(>= xs 20) (<= xs 30)) (and (>= xs 40) (<= xs 50))) ) (filter rango [10 15 25 40 30 27 42]) [25 40 30 27 42] => (filter (fn [xs] (or (and(>= xs 20) (<= xs 30)) (and (>= xs 40) (<= xs 50))) )[10 15 25 40 30 27 42]) [25 40 30 27 42] => (vreduce (fn [x y] (+ x y)) 0 [4 5 3]) 12 => (vreduce (fn [x y] (* x y)) 1 [4 5 3]) 60 => (vreduce (fn [x y] (conj x [(count x)y])) {} [10 20 30]) {0 10, 1 20, 2 30}
  • 5.
  • 6.
  • 7. (ns plf23072016.core (:require [plf23072016.fos :as fos] :reload )) (defn duplicados [xs] (fos/vmap (fn [x] ( * 2 x)) xs)) (clojure.string /trim "hola" (defn duplicados [xs] (fos/vmap (fn [x] (* 2 x))xs)) (ns proyecto03.core (:require [proyecto03.fos :as fos] :reload) ) (defn duplicados [xs] (fos/vmap (fn [x] (* 2 x))xs)) (duplicados [2 3 4]) [4 6 8] // (defn composicion-de [f g] (fn [x] (g (f x)))) => (fos/composicion-de (fn [x] (* 2 x)) (fn [x] (* 3 x)))
  • 8. => ((fn [x y] (letfn [(g [a v] (if (empty? v) a (g (+ a (first v)) (rest v))))] (g x y))) 0 [10 20 30]) 60 => ((fn [x y] (letfn [(g [a v] (if (empty? v) a (g (* a (first v)) (rest v))))] (g x y))) 1 [10 10 10]) 1000 18/07/2016 => (letfn [(g [zs ys] (if (empty? zs) ys (g (rest zs) (if (>= (count (first zs)) (count ys)) (first zs) ys ))))] (g [[]] [])) [] => (letfn [ (f [x] (* 2 x)) (g [x] (* 3 x))]) nil => (letfn [ (f [x] (* 2 x)) (g [x] (+ (f x) (f x)))] (g 5)) 20 => (letfn [(total-en [xs] (letfn [(g [ys a] (if (empty? ys) a (g (rest ys) (+ a (first ys)))))] (g xs 0)))] (total-en [10 20])) 30 => (letfn [(total-en [xs] (letfn [(g [ys a] (if (empty? ys) a (g (rest ys) (+ a (first ys)))))] (g xs 0)))
  • 9. (f [xs] (letfn [ (g [zs ys] (if (empty? zs) ys (g (rest zs) (if (> (total-en ys) (total-en (first zs)))ys (first zs)))))] (g xs [])))] (f [ [21 13] [20] [10]])) [21 13] => (conj [10 20] 30) [10 20 30] => (conj [10 20 30 40 50] 30 ) [10 20 30 40 50 30] => (conj [10 20 30 40 50] [30] ) [10 20 30 40 50 [30]] => (let [xs [10 20] ys (conj xs 30)] [xs ys]) [[10 20] [10 20 30]] => (letfn [(g [xs ys] (if (empty? xs) ys (g (rest xs) (conj ys (* 2 (first xs))))))] (g [2 3 4 ] [])) [4 6 8] => (letfn [(g [xs ys] (if (empty? xs) ys (g (rest xs) (conj ys (count(first xs))))))] (g [[ 2 3 ] [ 4 5 6]] [])) [2 3]d
  • 10. => '("" "" "" "") ("" "" "" "") => '("" "" "" "") ("" "" "" "") => ["hola" true true 4.9 3/2] ["hola" true true 4.9 3/2] => [a e i "o" "u"] [a e i "o" "u"] => {10 20 20 20 30 20 40 20} {10 20, 20 20, 30 20, 40 20} => (true false false true ) ClassCastException java.lang.Boolean cannot be cast to clojure.lang.IFn proyecto03.core/eval8026 (form-init6206876087026402955.clj:1) => (true false false true) ClassCastException java.lang.Boolean cannot be cast to clojure.lang.IFn proyecto03.core/eval8028 (form-init6206876087026402955.clj:1) => { true false false true} {true false, false true} => #{true false} #{true false} => # {true false true} RuntimeException Map literal must contain an even number of forms clojure.lang.Util.runtimeException (Util.java:221) => (count ' (10 20 30 40)) 4 => (empty? ' (10 20 30 40)) false => (list? ' (10 20 30 40)) true => (vector? ' (10 20 30 40)) false => (set? ' (10 20 30 40)) false => (map? ' (10 20 30 40)) false => (vector? [10 20 30]) true => ([10 20 30] 0) 10 => ({0 10 1 20 2 30 3 40}1) 20 => ({0 10 1 20 2 30 3 40}0) 10 => ({0 10 1 20 2 30 3 40}3)
  • 11. 40 => ({0 10 1 20 2 30 3 40}4) nil => ( #{ 10 20 30} 10 ) 10 => ( #{ 10 20 30} 20 ) 20 => ( #{ 10 20 30} 30 ) 30 => ( #{ 10 20 30} 40 ) nil ** por asociacion de un elmento al conjunto => (first '(10 20 30 40 50)) 10 => (rest '(10 20 30 40 50)) (20 30 40 50) => (rest '(20 30)) (30) => (rest [10 20 30]) (20 30) => (rest '(20 30)) (30) => (rest [10 20 30]) (20 30) => (first {10 20 30 40}) [10 20] => (rest {10 20 30 40}) ([30 40]) => (rest {10 20 30 40 50 60}) ([30 40] [50 60]) => (rest {50 60}) () => (first {}) nil => (first #{10 20 30}) 20 => (rest #{10 20 30}) (30 10) => (first #{ 30 10}) 30
  • 12. => ((fn [x] (> (count x)3)) [10 20 30 40]) true => ((fn [x] (> (count x)3)) {:a 10 :b 20 :c 30}) false => (((fn [x] (fn [y] (+ (first x) (first y))) ) [30 20 10]) [50 60]) 80 => (((fn [x] (fn [y] [(first x) (first y)]) ) [30 20 10]) [50 60]) [30 50] => (((fn [x] (fn [y] [(rest x) (rest y)]) ) [30 20 10]) [50 60]) [(20 10) (60)] => ((fn [x y] (if (> (count x) (count y))x y)) [10 20 30 40 50] [60 70 80 90] ) [10 20 30 40 50] => ((fn [x y] (if (> (count x) (count y))x y)) [10 20 30 40 50] [60 70 80 90 10 110] ) [60 70 80 90 10 110] => ((fn [x] [x x x x x]) "hola") ["hola" "hola" "hola" "hola" "hola"] => ((fn [x] [x x x x x]) [10 20 30]) [[10 20 30] [10 20 30] [10 20 30] [10 20 30] [10 20 30]]
  • 13. (defn f [x] (* 2 x)) (defn vmap [f xs] ( letfn [ (recursividad [g g2 zs] (if (empty? g2) zs (recursividad g (rest g2) (conj zs ( g (first g2)))) ) )] (recursividad f xs [] ))) (defn total-en [ xs] (letfn [ (recursividad [ys ac] (if (empty? ys ) ac (recursividad (rest ys) (+ ac (first ys )))))] (recursividad xs 0))) (defn mmap [f xs] (letfn [(recursividad [g g2 zs] (if (empty? g2) zs (recursividad g (rest g2) (conj zs [((first g2)0) (g ( (first g2)1))]))))] (recursividad f xs {}))) (defn filter [f xs] (letfn [(recursividad [g ys zs] (if (empty? ys) zs (recursividad g (rest ys) (if (g (first ys)) (conj zs (first ys)),zs))))] (recursividad f xs [])))
  • 14. (defn tiene-dos-elementos? [xs] (== (count xs)2)) (defn tiene-dos-elementosV? [xs] (and (vector? xs) (== (count xs)2))) (defn rango [xs] (or (and(>= xs 20) (<= xs 30)) (and (>= xs 40) (<= xs 50))) ) (defn mfilter [f xs] (letfn [(recursividad [g ys zs] (if (empty? ys) zs (recursividad g (rest ys) (if (g (first ys)1) (conj zs (first ys)) zs ))))] (recursividad f xs {}))) (defn vreduce [f vi xs] (letfn [(recursividad [g vf ys] (if (empty? ys) vf (recursividad g (g vf (first ys)) (rest ys))))] (recursividad f vi xs))) (defn vmap [f xs] ( letfn [ (recursividad [g g2 zs] (if (empty? g2) zs (recursividad g (rest g2) (conj zs ( g (first g2)))) ) )] (recursividad f xs [] )))
  • 15. (vmap (fn [x] (* 2 x)) [ 2 3 4]) [4 6 8] (defn mmap [f zs] (letfn [(recursividad [g g2 zs] (if (empty? g2) zs (recursividad g (rest g2) (conj zs [((first g2)0) (g ( (first g2)1))])))] => (filter tiene-dos-elementos? [[10 20] [30] [40 50]]) [[10 20] [40 50]] (defn filter [f xs] (letfn [(recursividad [g ys zs] (if (empty? ys) zs (recursividad g (rest ys) (if (g (first ys)) (conj zs (first ys)),zs))))] (recursividad f xs []))) (defn tiene-dos-elementos? [xs] (== (count xs)2)) => (filter tiene-dos-elementos? ["ho" "l" "a!"]) ["ho" "a!"] (defn tiene-dos-elementosV? [xs] (and (vector? xs) (== (count xs)2))) (filter tiene-dos-elementosV? [[10 20] 30 [40 50]]) [[10 20] [40 50]] tiene-dos-elementosV?
  • 16. (recursividad f xs {} ))) (defn rango [xs] (or (and(>= xs 20) (<= xs 30)) (and (>= xs 40) (<= xs 50))) ) (filter rango [10 15 25 40 30 27 42]) [25 40 30 27 42] => (filter (fn [xs] (or (and(>= xs 20) (<= xs 30)) (and (>= xs 40) (<= xs 50))) )[10 15 25 40 30 27 42]) [25 40 30 27 42] => (vreduce (fn [x y] (+ x y)) 0 [4 5 3]) 12 => (vreduce (fn [x y] (* x y)) 1 [4 5 3]) 60 => (vreduce (fn [x y] (conj x [(count x)y])) {} [10 20 30]) {0 10, 1 20, 2 30}
  • 17. 21 07 2016 (mmap (fn [x] (count x)) {:a [10 20] :b [30]}) {:a 2, :b 1} => (vmap (fn [x] (mmap (fn [x] (* 3 x))x)) [ {:a 10 } {:a 10 :b 20} {}]) [{:a 30} {:a 30, :b 60} {}] (defn cmap [f xs] ( letfn [ (recursividad [g g2 zs] (if (empty? g2) zs (recursividad g (rest g2) (conj zs ( g (first g2)))) ) )] (recursividad f xs #{} ))) => (cmap (fn [x] (* 2 x)) #{40 10 30}) #{20 60 80} => (vmap (fn [x] (filter (fn [x] (and (even? x ) (>= x 0)))x)) [[2 3 4] [-2 -4 6] [10 -3 -5 12 -9 6]]) [[2 4] [6] [10 12 6]] => (mmap (fn [x] (if (>= x 0) x (* -1 x))) {:a -3 :b 5 :c -9}) {:a 3, :b 5, :c 9} (defn cfilter [f xs] (letfn [(recursividad [g ys zs] (if (empty? ys) zs (recursividad g (rest ys) (if (g (first ys)) (conj zs (first ys)),zs))))]
  • 18. (recursividad f xs #{}))) => (cfilter (fn [x] (pos? x))#{10 -20 30}) #{30 10} (defn smap [f xs] (letfn [(recursividad [g ys zs] (if (empty? ys) zs (recursividad g (rest ys) (str zs (g (first ys))) )))] (recursividad f xs ""))) (defn en-mayuscula [c] ({a A e E i I o O u U} c)) (defn en-mayusculas [c] (let [mayusculas {a A e E i I o O u U} ] (if (nil? (mayusculas c)) c (mayusculas c)))) (smap en-mayuscula "aaaeee iiiooouuu") AAAEEEIIIOOOUUU => (smap en-mayusculas "aa ee") AA EE
  • 19.
  • 20.
  • 21. (ns plf23072016.core (:require [plf23072016.fos :as fos] :reload )) (defn duplicados [xs] (fos/vmap (fn [x] ( * 2 x)) xs)) (clojure.string /trim "hola" (defn duplicados [xs] (fos/vmap (fn [x] (* 2 x))xs)) (ns proyecto03.core (:require [proyecto03.fos :as fos] :reload) ) (defn duplicados [xs] (fos/vmap (fn [x] (* 2 x))xs)) (duplicados [2 3 4]) [4 6 8] // (defn composicion-de [f g] (fn [x] (g (f x)))) => (fos/composicion-de (fn [x] (* 2 x)) (fn [x] (* 3 x)))
  • 22.
  • 23.
  • 24.
  • 25. /////// (defn sfilter [f xs] (letfn [(recursividad [g ys zs] (if (empty? ys) zs (recursividad g (rest ys) (if (g (first ys)) (str zs (first ys)) zs ))))] (recursividad f xs "" )))
  • 26. ////////////// (sfilter (fn [x] (= x a)) "hola") ////// (f "hola") ---> "Hola" (f "hOLA")----> "Hola" (f "hola mundo")---> "Hola Mundo" ///// (defn vreduce [f vi xs] (letfn [(recursividad [g vf ys] (if (empty? ys) vf (recursividad g (g vf (first ys)) (rest ys))))] (recursividad f vi xs))) (vreduce(fn [x y] :conj x [:count x) y])) {:a 10} {"hola" "mundo"]) __ (vreduce (fn [ x y ] x) {} [2 -5 7-9 3 7]) ---(let (mapa {:a 10 :b 10}] (conj mapa { :a (+ 3 (mapa :a))])) ----{:a 13, :b 10} (fn [x y] (if (>= y 0)
  • 27. (conj x [:positivos (inc (x :positivos))]) (conj x [:negativos (inc (x :negativos))]))) { :positivos 0 :negativos 0} -8) => (vreduce (fn [x y] (if (>= y 0) (conj x [:positivos (inc (x :positivos))]) (conj x [:negativos (inc (x :negativos))]))) { :positivos 0 :negativos 0} [2 -3 4 -5 6 7]) {:positivos 4, :negativos 2} (sreduce (fn [x y] (conj x y)) [] (str 4567))
  • 28. => (let [x 10 y 20] (+ x y)) 30 => (let [ a 10 b 20 c 30] (* (+ a a) (+ b b) (+ c c)) ) 48000 => (let [x [ 10 20 30] y [ 40 50 60]] (+ (first x) (first y)) ) 50 => (let [x [10 20] y [ 30 40]] {:x x :y y}) {:x [10 20], :y [30 40]} => (let [x [50 60 70] y (first x)] x) [50 60 70] => (let [x [50 60 70] y (first x)] y) 50 => (let [x [ 50 60 70] y [10 20 30]] {:x x :y y :first-x (first x) :first-y (first y)}) {:x [50 60 70], :y [10 20 30], :first-x 50, :first-y 10} => (let [a (+ 2 3) b (* 2 3) c (+ a b)] {:a a :b b :c c}) {:a 5, :b 6, :c 11} => (let [x [ 50 60 70] y [10 20 30]] {:x x :y y :first-x (first x) :first-y (first y)}) {:x [50 60 70], :y [10 20 30], :first-x 50, :first-y 10}
  • 29. => (let [a true b true c true] (and a b c)) true => ((fn [x] (let [a 10 b 20 x 30] (+ a b x)))24) 60 => ((fn [x] (let [a 10 b 20 c 30] (+ a b x)))24) 54 => (if false (let [x 10] (* 2 x)) (let [x 20] (* 5 x))) 100 ((fn [x] (if (>= x 0) (let [ y 1] (* y x)) (let [y -1] (* y x)))) -65) 65 => (let [x -4] (if (>= x 10) (let [y (* x x)] y) (let [ y ( + x x)] y))) -8 (let [f (fn [x] (* 2 x)) g (fn [x] (* 3 x))] (f ( g 5))) 30 //aplicar a f con el resultado de g de 5
  • 30. => (let [f (fn [x] (* 2 x)) g (fn [x] (* 3 x)) h (f (g 7))] h) 42 => (let [f (fn [x] (* 2 x)) g (fn [x] (* 3 x)) h (f (g 7)) i (fn [x] {:resultado-final x})] (i h) ) {:resultado-final 42} recursividad--- => ((fn [x] (letfn [ (g [ ei ef i a ] (if (> i ef) a (g ei ef (inc i) (+ a i))))] (g 0 x 0 0))) 5) 15 => ((fn [x y] (letfn [ (g [ ei ef i a ] (if (> i ef) a (g ei ef (inc i) (+ a i))))] (g x y x x))) 0 5) 15 => ((fn [n] ((fn [x y] (letfn [ (g [ ei ef i a ] (if (> i ef) a (g ei ef (inc i) (+ a i))))] (g x y x x))) 0 n)) 5) 15 => ((fn [x y] (letfn [ (g [ ei ef c a ] (if (== ei ef) a (g (inc ei) ef c(+ a c))))] (g 0 x y 0))) 5 20) 100 => (rest [ 10 20 30])
  • 31. (20 30) => (rest (rest [10 20 30])) (30) => (first ( rest ( rest [10 20 30]))) 30 => (+ (firsst [10 20 30]) (first (rest [10 20 30])) (first (rest (rest [10 20 30])))) CompilerException java.lang.RuntimeException: Unable to resolve symbol: firsst in this context, compiling:(C:UsersxenosAppDataLocalTempform-init7869937070705144292.clj:1:4) => (+ (first [10 20 30]) (first (rest [10 20 30])) (first (rest (rest [10 20 30])))) 60
  • 32. => (let [x 10 y 20] (+ x y)) 30 => (let [ a 10 b 20 c 30] (* (+ a a) (+ b b) (+ c c)) ) 48000 => (let [x [ 10 20 30] y [ 40 50 60]] (+ (first x) (first y)) ) 50 => (let [x [10 20] y [ 30 40]] {:x x :y y}) {:x [10 20], :y [30 40]} => (let [x [50 60 70] y (first x)] x) [50 60 70] => (let [x [50 60 70] y (first x)] y) 50 => (let [x [ 50 60 70] y [10 20 30]] {:x x :y y :first-x (first x) :first-y (first y)}) {:x [50 60 70], :y [10 20 30], :first-x 50, :first-y 10} => (let [a (+ 2 3) b (* 2 3) c (+ a b)] {:a a :b b :c c}) {:a 5, :b 6, :c 11} => (let [x [ 50 60 70] y [10 20 30]] {:x x :y y :first-x (first x) :first-y (first y)}) {:x [50 60 70], :y [10 20 30], :first-x 50, :first-y 10}
  • 33. => (let [a true b true c true] (and a b c)) true => ((fn [x] (let [a 10 b 20 x 30] (+ a b x)))24) 60 => ((fn [x] (let [a 10 b 20 c 30] (+ a b x)))24) 54 => (if false (let [x 10] (* 2 x)) (let [x 20] (* 5 x))) 100 ((fn [x] (if (>= x 0) (let [ y 1] (* y x)) (let [y -1] (* y x)))) -65) 65 => (let [x -4] (if (>= x 10) (let [y (* x x)] y) (let [ y ( + x x)] y))) -8 (let [f (fn [x] (* 2 x)) g (fn [x] (* 3 x))] (f ( g 5))) 30 //aplicar a f con el resultado de g de 5
  • 34. => (let [f (fn [x] (* 2 x)) g (fn [x] (* 3 x)) h (f (g 7))] h) 42 => (let [f (fn [x] (* 2 x)) g (fn [x] (* 3 x)) h (f (g 7)) i (fn [x] {:resultado-final x})] (i h) ) {:resultado-final 42} recursividad--- => ((fn [x] (letfn [ (g [ ei ef i a ] (if (> i ef) a (g ei ef (inc i) (+ a i))))] (g 0 x 0 0))) 5) 15 => ((fn [x y] (letfn [ (g [ ei ef i a ] (if (> i ef) a (g ei ef (inc i) (+ a i))))] (g x y x x))) 0 5) 15 => ((fn [n] ((fn [x y] (letfn [ (g [ ei ef i a ] (if (> i ef) a (g ei ef (inc i) (+ a i))))] (g x y x x))) 0 n)) 5) 15 => ((fn [x y] (letfn [ (g [ ei ef c a ] (if (== ei ef) a (g (inc ei) ef c(+ a c))))] (g 0 x y 0))) 5 20) 100 => (rest [ 10 20 30])
  • 35. (20 30) => (rest (rest [10 20 30])) (30) => (first ( rest ( rest [10 20 30]))) 30 => (+ (firsst [10 20 30]) (first (rest [10 20 30])) (first (rest (rest [10 20 30])))) CompilerException java.lang.RuntimeException: Unable to resolve symbol: firsst in this context, compiling:(C:UsersxenosAppDataLocalTempform-init7869937070705144292.clj:1:4) => (+ (first [10 20 30]) (first (rest [10 20 30])) (first (rest (rest [10 20 30])))) 60
  • 36.
  • 37.
  • 38. (ns plf23072016.core (:require [plf23072016.fos :as fos] :reload )) (defn duplicados [xs] (fos/vmap (fn [x] ( * 2 x)) xs)) (clojure.string /trim "hola"
  • 39. => '("" "" "" "") ("" "" "" "") => '("" "" "" "") ("" "" "" "") => ["hola" true true 4.9 3/2] ["hola" true true 4.9 3/2] => [a e i "o" "u"] [a e i "o" "u"] => {10 20 20 20 30 20 40 20} {10 20, 20 20, 30 20, 40 20} => (true false false true ) ClassCastException java.lang.Boolean cannot be cast to clojure.lang.IFn proyecto03.core/eval8026 (form-init6206876087026402955.clj:1) => (true false false true) ClassCastException java.lang.Boolean cannot be cast to clojure.lang.IFn proyecto03.core/eval8028 (form-init6206876087026402955.clj:1) => { true false false true} {true false, false true} => #{true false} #{true false} => # {true false true} RuntimeException Map literal must contain an even number of forms clojure.lang.Util.runtimeException (Util.java:221) => (count ' (10 20 30 40)) 4 => (empty? ' (10 20 30 40)) false => (list? ' (10 20 30 40)) true => (vector? ' (10 20 30 40)) false => (set? ' (10 20 30 40)) false => (map? ' (10 20 30 40)) false => (vector? [10 20 30]) true => ([10 20 30] 0) 10 => ({0 10 1 20 2 30 3 40}1) 20 => ({0 10 1 20 2 30 3 40}0) 10 => ({0 10 1 20 2 30 3 40}3)
  • 40. 40 => ({0 10 1 20 2 30 3 40}4) nil => ( #{ 10 20 30} 10 ) 10 => ( #{ 10 20 30} 20 ) 20 => ( #{ 10 20 30} 30 ) 30 => ( #{ 10 20 30} 40 ) nil ** por asociacion de un elmento al conjunto => (first '(10 20 30 40 50)) 10 => (rest '(10 20 30 40 50)) (20 30 40 50) => (rest '(20 30)) (30) => (rest [10 20 30]) (20 30) => (rest '(20 30)) (30) => (rest [10 20 30]) (20 30) => (first {10 20 30 40}) [10 20] => (rest {10 20 30 40}) ([30 40]) => (rest {10 20 30 40 50 60}) ([30 40] [50 60]) => (rest {50 60}) () => (first {}) nil => (first #{10 20 30}) 20 => (rest #{10 20 30}) (30 10) => (first #{ 30 10}) 30
  • 41. => ((fn [x] (> (count x)3)) [10 20 30 40]) true => ((fn [x] (> (count x)3)) {:a 10 :b 20 :c 30}) false => (((fn [x] (fn [y] (+ (first x) (first y))) ) [30 20 10]) [50 60]) 80 => (((fn [x] (fn [y] [(first x) (first y)]) ) [30 20 10]) [50 60]) [30 50] => (((fn [x] (fn [y] [(rest x) (rest y)]) ) [30 20 10]) [50 60]) [(20 10) (60)] => ((fn [x y] (if (> (count x) (count y))x y)) [10 20 30 40 50] [60 70 80 90] ) [10 20 30 40 50] => ((fn [x y] (if (> (count x) (count y))x y)) [10 20 30 40 50] [60 70 80 90 10 110] ) [60 70 80 90 10 110] => ((fn [x] [x x x x x]) "hola") ["hola" "hola" "hola" "hola" "hola"] => ((fn [x] [x x x x x]) [10 20 30]) [[10 20 30] [10 20 30] [10 20 30] [10 20 30] [10 20 30]]
  • 42. ((fn [x] {(x 0) (x 1)}) [10 20]) {10 20} => (rest { :a 10 :b 20}) ([:b 20]) => ((fn [ x y] { x (* 4 x) y (* 4 y)})10 20) {10 40, 20 80} => ((fn [x] {(first x) x}) [50 20 40]) {50 [50 20 40]} => ((fn [x] {:anterior (dec x) :siguiente (inc x)})45) {:anterior 44, :siguiente 46} => ((fn [ x y z] #{x y z})10 20 30) #{20 30 10} => ((fn [x y] [{:x y} {:y x}])40 50) [{:x 50} {:y 40}] (fn [nombre apellido-paterno apellido-materno]) => ((fn [nombre apellido-paterno apellido-materno] {:nombre nombre :apellido { :paterno apellido-paterno :materno apellido-materno}} ) "Joaquin" "Martinez" "Benjamin") {:nombre "Joaquin", :apellido {:paterno "Martinez", :materno "Benjamin"}} => #{[10 20] [30 40] [20 10]} #{[20 10] [10 20] [30 40]}
  • 43. => '("" "" "" "") ("" "" "" "") => '("" "" "" "") ("" "" "" "") => ["hola" true true 4.9 3/2] ["hola" true true 4.9 3/2] => [a e i "o" "u"] [a e i "o" "u"] => {10 20 20 20 30 20 40 20} {10 20, 20 20, 30 20, 40 20} => (true false false true ) ClassCastException java.lang.Boolean cannot be cast to clojure.lang.IFn proyecto03.core/eval8026 (form-init6206876087026402955.clj:1) => (true false false true) ClassCastException java.lang.Boolean cannot be cast to clojure.lang.IFn proyecto03.core/eval8028 (form-init6206876087026402955.clj:1) => { true false false true} {true false, false true} => #{true false} #{true false} => # {true false true} RuntimeException Map literal must contain an even number of forms clojure.lang.Util.runtimeException (Util.java:221) => (count ' (10 20 30 40)) 4 => (empty? ' (10 20 30 40)) false => (list? ' (10 20 30 40)) true => (vector? ' (10 20 30 40)) false => (set? ' (10 20 30 40)) false => (map? ' (10 20 30 40)) false => (vector? [10 20 30]) true => ([10 20 30] 0) 10 => ({0 10 1 20 2 30 3 40}1) 20 => ({0 10 1 20 2 30 3 40}0) 10 => ({0 10 1 20 2 30 3 40}3)
  • 44. 40 => ({0 10 1 20 2 30 3 40}4) nil => ( #{ 10 20 30} 10 ) 10 => ( #{ 10 20 30} 20 ) 20 => ( #{ 10 20 30} 30 ) 30 => ( #{ 10 20 30} 40 ) nil ** por asociacion de un elmento al conjunto => (first '(10 20 30 40 50)) 10 => (rest '(10 20 30 40 50)) (20 30 40 50) => (rest '(20 30)) (30) => (rest [10 20 30]) (20 30) => (rest '(20 30)) (30) => (rest [10 20 30]) (20 30) => (first {10 20 30 40}) [10 20] => (rest {10 20 30 40}) ([30 40]) => (rest {10 20 30 40 50 60}) ([30 40] [50 60]) => (rest {50 60}) () => (first {}) nil => (first #{10 20 30}) 20 => (rest #{10 20 30}) (30 10) => (first #{ 30 10}) 30
  • 45. => ((fn [x] (> (count x)3)) [10 20 30 40]) true => ((fn [x] (> (count x)3)) {:a 10 :b 20 :c 30}) false => (((fn [x] (fn [y] (+ (first x) (first y))) ) [30 20 10]) [50 60]) 80 => (((fn [x] (fn [y] [(first x) (first y)]) ) [30 20 10]) [50 60]) [30 50] => (((fn [x] (fn [y] [(rest x) (rest y)]) ) [30 20 10]) [50 60]) [(20 10) (60)] => ((fn [x y] (if (> (count x) (count y))x y)) [10 20 30 40 50] [60 70 80 90] ) [10 20 30 40 50] => ((fn [x y] (if (> (count x) (count y))x y)) [10 20 30 40 50] [60 70 80 90 10 110] ) [60 70 80 90 10 110] => ((fn [x] [x x x x x]) "hola") ["hola" "hola" "hola" "hola" "hola"] => ((fn [x] [x x x x x]) [10 20 30]) [[10 20 30] [10 20 30] [10 20 30] [10 20 30] [10 20 30]]
  • 46. ((fn [x] {(x 0) (x 1)}) [10 20]) {10 20} => (rest { :a 10 :b 20}) ([:b 20]) => ((fn [ x y] { x (* 4 x) y (* 4 y)})10 20) {10 40, 20 80} => ((fn [x] {(first x) x}) [50 20 40]) {50 [50 20 40]} => ((fn [x] {:anterior (dec x) :siguiente (inc x)})45) {:anterior 44, :siguiente 46} => ((fn [ x y z] #{x y z})10 20 30) #{20 30 10} => ((fn [x y] [{:x y} {:y x}])40 50) [{:x 50} {:y 40}] (fn [nombre apellido-paterno apellido-materno]) => ((fn [nombre apellido-paterno apellido-materno] {:nombre nombre :apellido { :paterno apellido-paterno :materno apellido-materno}} ) "Joaquin" "Martinez" "Benjamin") {:nombre "Joaquin", :apellido {:paterno "Martinez", :materno "Benjamin"}} => #{[10 20] [30 40] [20 10]} #{[20 10] [10 20] [30 40]}