Guest User

Untitled

a guest
Feb 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. 25
  2. #(filter odd? %)
  3.  
  4. 39
  5. #(mapcat vector %1 %2)
  6. Mapcat function can take a collection of number
  7.  
  8. ?44
  9. (fn [i nums]
  10. (take (count nums)
  11. (drop (mod i (count nums))
  12.             (cycle nums)))
  13.  
  14. (fn [i nums]
  15. (if (pos? nums)
  16. (drop (count nums)
  17. else
  18. (take (mod i(count nums))
  19. /* if statement is good way for this problem, and I tried, but it does not work.*/
  20.  
  21. /*classnote
  22. (take 3 (range 10))
  23. (drop 3 (range 10))
  24. (concat (drop 3 (range 10)) (take 3 (range 10))
  25. */
  26.  
  27. 45
  28. [1 4 7 10 13]
  29. 1, 1+3, 4+3, 7+3, 10+3
  30.  
  31. 48
  32. 6
  33.  
  34. 50
  35. (comp vals (partial group-by type))
  36.  
  37. /*comp: Take a set of functions and reaturns a fn that is the composition.
  38. partial: Takes a function f and fewer than the normal arguments to f, and
  39. returns a fn that takes a variable number of additional args.
  40. group-by: Make group by argument.
  41. type: This is argument
  42. This separete by group-by function with type.
  43. */
  44.  
  45.  
  46. 51
  47. (range 1 6)
  48.  
  49. 61
  50. #(apply hash-map (interleave %1 %2))
  51. /*apply hash-map: Return a new has map with suupplied mapping
  52. interleave: Return seq of the first item in each coll, then return 2nd coll...*/
  53. /*Connect %1 and %2 content by interleave function.
  54.  
  55. 81
  56. (fn [x y] (set(filter #(contains? x %) y)))
  57. /*set: returns a set of the distinct elements of coll
  58. contains?: Checking y have content of x */
  59. /*define x and y. filter and contain fucntion check overlap content in x and y.*/
  60.  
  61. 90
  62. (fn [x y] (set (for [z x v y ] [z v])))
  63. /*Using for that making conbination of x and y.*/
  64.  
  65. 107
  66. (fn [x]
  67. (fn [y]
  68. (apply * (repeat x y)))
  69. )
  70. /*define x and y. repeat y x times. Apply multiply.*/
  71.  
  72.  
  73.  
  74. /*Question
  75. What hash-map is doing?
  76. hash map convert the list to map
  77.  
  78. What set function is doing?
  79. set convert the list to set stuff.
  80. */
  81.  
  82. /*
  83. (defn my-sum [&args]
  84. if (empty? args)
  85. 0
  86. (+ (first args)
  87.       (apply my-sum (rest args))))
  88. */
  89.  
  90. /*((comp f g) x)
  91. = (f (g x))
  92.  
  93. (->7 inc double double inc)
  94. 7+1=8 8*2=16 16*2 =32 32+1=33
  95. */
Add Comment
Please, Sign In to add comment