all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tom Capey <tom@edina.co.uk>
Subject: Re: Creating string from list of strings
Date: 14 Oct 2002 16:15:29 +0100	[thread overview]
Message-ID: <u65w5rqzy.fsf@edina.co.uk> (raw)
In-Reply-To: ubs5xp1co.fsf@terrapin.northbound-train.com

* Joe Casadonte <jcasadonte@northbound-train.com> writes:

>On Mon, 14 Oct 2002, Bill Wohler wrote:
> [question on concatenating list strings elided]

> Some folks have already showed you what to do to get a simple concat
> like you had asked for.  Here's something I whipped up to get a
> perl-like join command.
> 
> (defun my-perl-join (join-string elements)
>   "[Internal] Function to mimic Perl's join() function.
> 
> JOIN-STRING is the string to use to join them together.
> ELEMENTS is a list of what to join.
> 
> Example:
> 
>   \(my-perl-join \"/\" (list \"some\" \"file\" \"path\")
> 
> would result in the string:
> 
>   some/file/path
> 
> Note that no leading slash is put in; JOIN-STRING is only put in
> between the joined elements."
>   (let (rc active subsequent-pass)
> 	(while elements
> 	  (setq active (car elements))
> 	  (setq elements (cdr elements))
> 
>  	  (if (not subsequent-pass)
>  		  (setq subsequent-pass t)
> 		(setq rc (concat rc join-string))
> 		)
> 
> 	  (setq rc (concat rc active)))
> 	rc))
> 


  or using the cl package' `loop':

(loop for elts on (list "some" "file" "path")
      if (cdr elts)
      concat (concat (car elts) "/")
      else concat (car elts))


/Tom
-- 
"...and so, as the La-La of time plays with the Tinky-Winky of
destiny, and the Dipsy of fate sits on the Po of eternity."
						      -- Humph

  reply	other threads:[~2002-10-14 15:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-14  6:26 Creating string from list of strings Bill Wohler
2002-10-14  7:00 ` Stefan Monnier <foo@acm.com>
2002-10-14  7:05 ` John Paul Wallington
2002-10-14 14:00 ` Joe Casadonte
2002-10-14 15:15   ` Tom Capey [this message]
2002-10-14 15:35   ` Stefan Monnier <foo@acm.com>
2002-10-14 17:09     ` Joe Casadonte
2002-10-14 21:00     ` Bill Wohler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=u65w5rqzy.fsf@edina.co.uk \
    --to=tom@edina.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.