Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #59816
| From | "Robert L." <No_spamming@noWhere_7073.org> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | .re: How to split a string (or arbitrary sequence) at each occurrence of a value. |
| Date | 2017-05-25 09:59 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <og69ur$bbv$1@gioia.aioe.org> (permalink) |
> > What is the best, easiest, fastest, etc, way to split a string into
> > substrings based on a character position. In Emacs Lisp I would just:
>
> This may not be fast (I don't know), but it's straight-forward and readable.
>
> (defun split (string &optional (delimiter #\Space))
> (with-input-from-string (*standard-input* string)
> (let ((*standard-output* (make-string-output-stream)))
> (nconc (loop for char = (read-char nil nil nil)
> while char
> if (char= char delimiter)
> collect (get-output-stream-string *standard-output*)
> else
> do (write-char char))
> (list (get-output-stream-string *standard-output*))))))
Racket:
(regexp-split " +" "CL is actually COBOL in disguise")
=> '("CL" "is" "actually" "COBOL" "in" "disguise")
In Forth?
--
Air China is "Racist" for Telling the Truth About Non-White London Hoods.
Air China's in-flight magazine warned passengers about dangerous non-White
London neighborhoods and created an outrage, although Chinese have been victims
of non-White crime while visiting Europe.
https://archive.org/details/youtube-B7uEbKzwbiI
Back to comp.lang.forth | Previous | Next | Find similar | Unroll thread
.re: How to split a string (or arbitrary sequence) at each occurrence of a value. "Robert L." <No_spamming@noWhere_7073.org> - 2017-05-25 09:59 +0000
csiph-web