[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
first-is (3 versions, Elisp hangup) (was: Re: we need *modularity* [last
From: |
Emanuel Berg |
Subject: |
first-is (3 versions, Elisp hangup) (was: Re: we need *modularity* [last problem]) |
Date: |
Fri, 16 Aug 2024 11:35:23 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Here is one example. How to check if a word starts with
something? E.g., a "-" (not a dash anymore but
a "hyphen-minus", haha) then that should denote something
else, a line in this case, such situations.
How do you check that? And it cannot break for data that is
(not stringp), should just be nil then
I was doing something else, now I did this instead. I'm sure
you have a much better method that will make me look like
a fool, but ... it is like this all the time with Elisp.
Why isn't there just a (first-is THIS ALL) and it would not
crash, just eval to nil on type incompatibilities, other than
that it would work on arbitrary data? THIS could even be
a predicate that would take FRST as the argument.
Hey ... not bad! I should write that!
See the problem? :P
(defun elpat--first-is-3 (s str)
(and (stringp s)
(stringp str)
(string= s (char-to-string (seq-first str)))))
(defun elpat--first-is-2 (s str)
(and (stringp s)
(stringp str)
(string= s (substring str 0 1))))
(defun elpat--first-is (s str)
(and (cl-every #'stringp (list s str))
#1=(string-match s str)
(zerop #1#)))
;; (elpat--first-is "s" "same")
;; (elpat--first-is-2 "s" "same")
;; (elpat--first-is-3 "s" "same")
;; (elpat--first-is "s" "lame")
;; (elpat--first-is-2 "s" "lame")
;; (elpat--first-is-3 "s" "lame")
--
underground experts united
https://dataswamp.org/~incal
- Re: as for Calc and the math library, (continued)
- Re: as for Calc and the math library, Suhail Singh, 2024/08/14
- Re: as for Calc and the math library, Eli Zaretskii, 2024/08/14
- Re: as for Calc and the math library, Suhail Singh, 2024/08/14
- Re: as for Calc and the math library, Eli Zaretskii, 2024/08/14
- Re: as for Calc and the math library, Emanuel Berg, 2024/08/15
- Sv: as for Calc and the math library, arthur miller, 2024/08/15
- Re: as for Calc and the math library, Eli Zaretskii, 2024/08/15
- Sv: as for Calc and the math library, arthur miller, 2024/08/16
- Re: as for Calc and the math library, Eli Zaretskii, 2024/08/16
- we need *modularity* [last problem] (was: Re: as for Calc and the math library), Emanuel Berg, 2024/08/16
- first-is (3 versions, Elisp hangup) (was: Re: we need *modularity* [last problem]),
Emanuel Berg <=
- Re: first-is (3 versions, Elisp hangup) (was: Re: we need *modularity* [last problem]), Emanuel Berg, 2024/08/16
- Re: first-is (3 versions, Elisp hangup) (was: Re: we need *modularity* [last problem]), Eli Zaretskii, 2024/08/16
- Re: as for Calc and the math library, Richard Stallman, 2024/08/18
- as for Calc and the math library, Christopher Dimech, 2024/08/18
- Sv: as for Calc and the math library, arthur miller, 2024/08/19
- Re: as for Calc and the math library, Richard Stallman, 2024/08/23
- Re: as for Calc and the math library, Richard Stallman, 2024/08/23
- Emacs ffi (was: Re: as for Calc and the math library), Andrea Corallo, 2024/08/15
- Re: Emacs ffi (was: Re: as for Calc and the math library), Eli Zaretskii, 2024/08/15
- Re: Emacs ffi, Andrea Corallo, 2024/08/15