Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
17
Task/Call-a-function/Clojure/call-a-function-14.clj
Normal file
17
Task/Call-a-function/Clojure/call-a-function-14.clj
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
(defn apply-discount [discount-percentage price]
|
||||
"Function to apply a discount to a price"
|
||||
(-> price
|
||||
(* (- 100 discount-percentage)) ;; Apply discount
|
||||
(/ 100.0)))
|
||||
|
||||
;; Here we have assigned the variable to a partial function
|
||||
;; It means 'call apply-discount with 10 as the first argument'
|
||||
(def discount-10pc-option-1 (partial apply-discount 10))
|
||||
|
||||
;; And is equivalent to this:
|
||||
(defn discount-10pc-option-2 [price]
|
||||
(apply-discount 10 price))
|
||||
|
||||
(discount-10pc-option-1 100); => 90
|
||||
|
||||
(discount-10pc-option-2 100); => 90
|
||||
Loading…
Add table
Add a link
Reference in a new issue