Last active
November 7, 2024 22:53
-
-
Save PEZ/fcd991cd17eb81a7e9a42d84a0cda89f to your computer and use it in GitHub Desktop.
Re-implement Map – Rich 4Clojure Problem 118 – See: https://github.com/PEZ/rich4clojure
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 rich4clojure.easy.problem-118 | |
| (:require [hyperfiddle.rcf :refer [tests]])) | |
| ;; = Re-implement Map = | |
| ;; By 4Clojure user: semisight | |
| ;; Difficulty: Easy | |
| ;; Tags: [core-seqs] | |
| ;; | |
| ;; Map is one of the core elements of a functional | |
| ;; programming language. Given a function f and an input | |
| ;; sequence s, return a lazy sequence of (f x) for each | |
| ;; element x in s . | |
| (def restricted [map map-indexed mapcat for]) | |
| (def __ :tests-will-fail) | |
| (comment | |
| ) | |
| (tests | |
| [3 4 5 6 7] := | |
| (__ inc [2 3 4 5 6]) | |
| (repeat 10 nil) := | |
| (__ (fn [_] nil) (range 10)) | |
| [1000000 1000001] := | |
| (->> (__ inc (range)) | |
| (drop (dec 1000000)) | |
| (take 2))) | |
| ;; To participate, fork: | |
| ;; https://github.com/PEZ/rich4clojure | |
| ;; Post your solution below, please! |
oezg
commented
Nov 7, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment