SlideShare a Scribd company logo
1 of 50
Download to read offline
(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

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 181Mahmoud 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 185Mahmoud 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-eFernandoDanielMamani1
 
ตัวอย่างข้อสอบเก่า วิชาคณิตศาสตร์ ม.6 ปีการศึกษา 2553
ตัวอย่างข้อสอบเก่า วิชาคณิตศาสตร์ ม.6 ปีการศึกษา 2553ตัวอย่างข้อสอบเก่า วิชาคณิตศาสตร์ ม.6 ปีการศึกษา 2553
ตัวอย่างข้อสอบเก่า วิชาคณิตศาสตร์ ม.6 ปีการศึกษา 2553Destiny Nooppynuchy
 
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 180Mahmoud Samir Fayed
 
ゲーム理論BASIC 第38回 -続・カーネル-
ゲーム理論BASIC 第38回 -続・カーネル-ゲーム理論BASIC 第38回 -続・カーネル-
ゲーム理論BASIC 第38回 -続・カーネル-ssusere0a682
 
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 ProblemsSunil Yadav
 
S1 3 derivadas_resueltas
S1 3 derivadas_resueltasS1 3 derivadas_resueltas
S1 3 derivadas_resueltasjesquerrev1
 
LeetCode April Coding Challenge
LeetCode April Coding ChallengeLeetCode April Coding Challenge
LeetCode April Coding ChallengeSunil 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-1Jimbo 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 wholeIlan Godik
 

What's hot (20)

1010n3a
1010n3a1010n3a
1010n3a
 
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
Tugasmatematikakelompokgundul28
 
Tugas matematika kelompok
Tugas matematika kelompokTugas matematika kelompok
Tugas matematika kelompokachmadtrybuana
 
Re:ゲーム理論入門 第14回 - 仁 -
Re:ゲーム理論入門 第14回 - 仁 -Re:ゲーム理論入門 第14回 - 仁 -
Re:ゲーム理論入門 第14回 - 仁 -ssusere0a682
 
Tugasmatematikakelompok 150715235527-lva1-app6892
Tugasmatematikakelompok 150715235527-lva1-app6892Tugasmatematikakelompok 150715235527-lva1-app6892
Tugasmatematikakelompok 150715235527-lva1-app6892drayertaurus
 
Hitchhiker's Guide to Functional Programming
Hitchhiker's Guide to Functional ProgrammingHitchhiker's Guide to Functional Programming
Hitchhiker's Guide to Functional ProgrammingSergey Shishkin
 
Interpolation functions
Interpolation functionsInterpolation functions
Interpolation functionsTarun Gehlot
 
数式処理ソフトMathematicaで数学の問題を解く
数式処理ソフトMathematicaで数学の問題を解く数式処理ソフトMathematicaで数学の問題を解く
数式処理ソフトMathematicaで数学の問題を解くYoshihiro Mizoguchi
 
jhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfg
jhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfgjhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfg
jhkl,l.มือครูคณิตศาสตร์พื้นฐาน ม.4 สสวท เล่ม 2fuyhfgTonn Za
 
chap 2 Ex#1.1
chap 2 Ex#1.1chap 2 Ex#1.1
chap 2 Ex#1.1Ans Ali
 
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-tableMonique 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 SystemsAmr E. Mohamed
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語ikdysfm
 
Integral table
Integral tableIntegral table
Integral tableAnkitcos0
 

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

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

Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 

Recently uploaded (20)

Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 

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]}