Created
May 27, 2015 04:24
-
-
Save nihilismus/53406cb2669be11efb7b to your computer and use it in GitHub Desktop.
plf.core
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns plf.core) | |
(defn isa01 | |
[xs] | |
(map (fn [x] (/ x 2)) xs)) | |
(defn isa02 | |
[xs] | |
(map count xs)) | |
(defn isa03 | |
[xs] | |
(let [es-multiplo-de-diez? (fn [x] (and (>= x 10) (= (rem x 10) 0))) | |
todos-son-verdaderos (fn [x y] (and x y))] | |
(reduce todos-son-verdaderos | |
(map es-multiplo-de-diez? xs)))) | |
(defn isa04 | |
[xss] | |
(let [la-cantidad-de-vectores-anidados (count xss) | |
numero-de-elementos-al-primer-vector-anidado (count (get xss 0)) | |
la-cantidad-de-vectores-anidados-con-igual (fn [x] (count (filter (fn [xs] (= (count xs) x)) xss))) | |
es-igual? (fn [x y] (= x y))] | |
(es-igual? | |
la-cantidad-de-vectores-anidados | |
(la-cantidad-de-vectores-anidados-con-igual numero-de-elementos-al-primer-vector-anidado)))) | |
(defn isa05 | |
[xs] | |
(let [el-antecesor-y-el-sucesor-de (fn [x] [(dec x) (inc x)])] | |
(map el-antecesor-y-el-sucesor-de xs))) | |
(defn isb01 | |
[xs] | |
(map last xs)) | |
(defn isb02 | |
[xss] | |
(let [tiene-dos-elementos? (fn [xs] (= (count xs) 2))] | |
(filter tiene-dos-elementos? xss))) | |
(defn isb03 | |
[xss] | |
(let [veces-repetido-el-numero-treinta-en (fn [xs] (reduce | |
(fn [x y] | |
(if (= 30 y) (inc x) x)) | |
0 | |
xs)) | |
cantidad-de (fn [xs] (reduce + xs)) | |
es-mas-de-cero-la? (fn [x] (> x 0))] | |
(es-mas-de-cero-la? | |
(cantidad-de (map | |
veces-repetido-el-numero-treinta-en xss))))) | |
(defn isb05 | |
[xs] | |
(let [el-doble-de (fn [x] (* 2 x)) | |
un-mapa (fn [x] {x (el-doble-de x)})] | |
(map un-mapa xs))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment