I'd like to find if there is a substring in any of the strings in my list of strings. I have a list like '("hi" "hey" "hello"). Using "some" I can find if the value "hi" is in this list. But how could I find if just "h" was in at least one of the strings in the list?
1 Answer
Clojure solutions:
includes?fromclojure.string
(some #(clojure.string/includes? % "h") (list "hi" "hello" "hey"))
containsvia Java Interop
(some #(.contains % "h") (list "hi" "hello" "hey"))
ClojureScript solutions:
includes?fromclojure.string(requireclojure.stringinnsform)
(ns my-app.core
(:require [clojure.string :as string]))
(some #(string/includes? % "h") (list "hi" "hello" "hey"))
includesvia JavaScript Interop
(some #(.includes % "h") (list "hi" "hello" "hey"))
someto check if"hi"is in the list?(some #(clojure.string/includes? % "h") ["hi" "hello" "hey"])