Re: string search and assignment

Liste des GroupesRevenir à cl lisp 
Sujet : Re: string search and assignment
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.lisp
Date : 03. Jul 2024, 01:23:53
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240702160629.519@kylheku.com>
References : 1
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-07-02, B. Pym <No_spamming@noWhere_7073.org> wrote:
Gauche Scheme
>
(use file.util) ;; file->string-list
(use srfi-13) ;; string-tokenize
(use srfi-14) ;; character-sets

This is garbage. If it comes with the language, the language should
understand it without any import statement nonsense.

(At least a high-level, dynamic language. Medium-level, non-interactive
languages like Ada and Modula-2 have decent reasons for it.)

;; Assumes that the "next word" has to be on the same line.
(define (find-word-association-in-file word file)
  (any
    (lambda (line)
      (let* ((words (string-tokenize line char-set:letter))
             (tail (member word words string=?)))
        (and tail (pair? (cdr tail)) (cadr tail))))
    (file->string-list file)))

TXR Lisp:

(defun find-following-word-in-file (path word)
  (if-match @(some @(scan (@word @other . @nil)))
            (mapcar (op tok #/\w+/) (file-get-lines path))
    other))

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Date Sujet#  Auteur
2 Jul 24 * Re: string search and assignment2B. Pym
3 Jul 24 `- Re: string search and assignment1Kaz Kylheku

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal