Skip to content

Instantly share code, notes, and snippets.

View PEZ's full-sized avatar
🎯
Focusing

Peter Strömberg PEZ

🎯
Focusing
View GitHub Profile
@PEZ
PEZ / rich4clojure_easy_problem_061.clj
Last active April 25, 2024 18:50
Map Construction – Rich 4Clojure Problem 61 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.easy.problem-061
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Map Construction =
;; By 4Clojure user: dbyrne
;; Difficulty: Easy
;; Tags: [core-functions]
;;
;; Write a function which takes a vector of keys and a
;; vector of values and constructs a map from them.
@PEZ
PEZ / rich4clojure_easy_problem_042.clj
Last active April 25, 2024 18:31
Factorial Fun – Rich 4Clojure Problem 42 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.easy.problem-042
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Factorial Fun =
;; By 4Clojure user: amalloy
;; Difficulty: Easy
;; Tags: [math]
;;
;; Write a function which calculates factorials.
@PEZ
PEZ / rich4clojure_easy_problem_041.clj
Last active April 25, 2024 18:28
Drop Every Nth Item – Rich 4Clojure Problem 41 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.easy.problem-041
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Drop Every Nth Item =
;; By 4Clojure user: dbyrne
;; Difficulty: Easy
;; Tags: [seqs]
;;
;; Write a function which drops every Nth item from a
;; sequence.
@PEZ
PEZ / rich4clojure_easy_problem_034.clj
Last active April 25, 2024 15:57
Implement range – Rich 4Clojure Problem 34 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.easy.problem-034
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Implement range =
;; By 4Clojure user: dbyrne
;; Difficulty: Easy
;; Tags: [seqs core-functions]
;;
;; Write a function which creates a list of all integers
;; in a given range.
@PEZ
PEZ / rich4clojure_easy_problem_032.clj
Last active April 25, 2024 15:55
Duplicate a Sequence – Rich 4Clojure Problem 32 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.easy.problem-032
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Duplicate a Sequence =
;; By 4Clojure user: dbyrne
;; Difficulty: Easy
;; Tags: [seqs]
;;
;; Write a function which duplicates each element of a
;; sequence.
@PEZ
PEZ / rich4clojure_elementary_problem_156.clj
Last active March 30, 2024 17:01
Map Defaults – Rich 4Clojure Problem 156 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.elementary.problem-156
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Map Defaults =
;; By 4Clojure user: jaycfields
;; Difficulty: Elementary
;; Tags: [seqs]
;;
;; When retrieving values from a map, you can specify
;; default values in case the key is not found:
@PEZ
PEZ / dumdom_defcomponent_macro.clj
Created February 18, 2024 09:37
A workaround to make default linting resolve `dumdom.core/defcomponent` without complaints.
(ns my-dumdom.macros
(:require [dumdom.core :as dumdom]))
(defn- extract-docstr
[[docstr? & forms]]
(if (string? docstr?)
[docstr? forms]
["" (cons docstr? forms)]))
(defn- extract-opts
@PEZ
PEZ / config.edn
Created February 18, 2024 08:06
A clj-kondo hook for Dumdom components `.clj-kondo/hooks/dumdom.clj`
{:linters {:dumdom/component-options {:level :warning}}
:hooks {:analyze-call {dumdom.core/defcomponent hooks.dumdom/defcomponent}}}
@PEZ
PEZ / rich4clojure_easy_problem_021.clj
Last active January 10, 2024 09:00
Nth Element – Rich 4Clojure Problem 21 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.easy.problem-021
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Nth Element =
;; By 4Clojure user: dbyrne
;; Difficulty: Easy
;; Tags: [seqs core-functions]
;;
;; Write a function which returns the Nth element from a
;; sequence.
@PEZ
PEZ / rich4clojure_easy_problem_022.clj
Last active December 30, 2023 03:37
Count a Sequence – Rich 4Clojure Problem 22 – See: https://github.com/PEZ/rich4clojure
(ns rich4clojure.easy.problem-022
(:require [hyperfiddle.rcf :refer [tests]]))
;; = Count a Sequence =
;; By 4Clojure user: dbyrne
;; Difficulty: Easy
;; Tags: [seqs core-functions]
;;
;; Write a function which returns the total number of
;; elements in a sequence.