Skip to content

Instantly share code, notes, and snippets.

@PEZ
Last active October 13, 2024 21:03
Show Gist options
  • Save PEZ/b00355c5b51c4e29e27a09b6ed2f7a73 to your computer and use it in GitHub Desktop.
Save PEZ/b00355c5b51c4e29e27a09b6ed2f7a73 to your computer and use it in GitHub Desktop.
Double Down – Rich 4Clojure Problem 15 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.elementary.problem-015
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Double Down =
;; By 4Clojure user: dbyrne
;; Difficulty: Elementary
;;
;; Write a function which doubles a number.
(def __ :tests-will-fail)
(comment
)
(tests
(__ 2) := 4
(__ 3) := 6
(__ 11) := 22
(__ 7) := 14)
;; To participate, fork:
;; https://github.com/PEZ/rich4clojure
;; Post your solution below, please!
@froucoux
Copy link

froucoux commented Oct 2, 2024

;;(def __ (fn [x] (* 2 x)))
;; (def __ #(* 2 %))
;; (def __ (partial * 2))
(def __ (fn double [x] (* 2 x)))

@oezg
Copy link

oezg commented Oct 13, 2024

(def __ (fn double-down [n] ((partial * 2) n)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment