Digital Mark λ 📚 🕹 💾 🥃 on Nostr: Every goddamned time I have to write #'foo and funcall, I am sure COMMON LISPers do ...
Every goddamned time I have to write #'foo and funcall, I am sure COMMON LISPers do not understand the word "fun".
;; Test whether 'haystack' ends with 'needle'. :ci case-insensitive
(defun string-has-suffixp (haystack needle &key ((:ci ci) NIL))
(let* ( (test (if ci #'string-equal #'string=))
(hlen (length haystack)) (nlen (length needle))
)
(and (> hlen 0)
(> nlen 0)
(<= nlen hlen)
(funcall test haystack needle :start1 (- hlen nlen) :end1 hlen)
)))
#lisp
Published at
2024-12-28 09:08:29Event JSON
{
"id": "0d935bdd5255f0096766ae79d4c5570c3fad35d34e766e0ebeb0daa6fddb195e",
"pubkey": "fb87acbaf8ba707e56cf4f028fd6cc1e99b8a78fe8327cab70915f15631b0672",
"created_at": 1735376909,
"kind": 1,
"tags": [
[
"t",
"lisp"
],
[
"proxy",
"https://appdot.net/users/mdhughes/statuses/113729661163679514",
"activitypub"
]
],
"content": "Every goddamned time I have to write #'foo and funcall, I am sure COMMON LISPers do not understand the word \"fun\".\n\n;; Test whether 'haystack' ends with 'needle'. :ci case-insensitive\n(defun string-has-suffixp (haystack needle \u0026key ((:ci ci) NIL))\n (let* ( (test (if ci #'string-equal #'string=))\n (hlen (length haystack)) (nlen (length needle))\n )\n (and (\u003e hlen 0)\n (\u003e nlen 0)\n (\u003c= nlen hlen)\n (funcall test haystack needle :start1 (- hlen nlen) :end1 hlen)\n)))\n#lisp",
"sig": "2c93757c921d80b27001690dc0d278239c9a5b4a53487b86eef0082fc7cf8bccb200ca3a1349911e983e91ec94a3d1a4428c84d81edcc64ffd54b49530389002"
}