From: Tushar Saxena
Subject: Concatenate strings in common lisp.
Date: 
Message-ID: <393@hilbert.albany.edu>
I would like to know how to concatenate two strings in common lisp (KCL)
the way you do it in Franz Lisp using concat.

Thanks

	-Tushar Saxena

From: Marty Hall
Subject: Re: Concatenate strings in common lisp. [really help without CltL]
Date: 
Message-ID: <1991Aug13.193301.1699@aplcen.apl.jhu.edu>
······@cs.albany.edu (Tushar Saxena) writes:
>I would like to know how to concatenate two strings in common lisp (KCL)
>the way you do it in Franz Lisp using concat.

As the author knows by now, "concatenate" was the appropriate function.

It might be worth reminding those without a copy of CLtL (or _Common LISP
the Reference_ or the Symbolics Document Examiner) handy that you can
still get useful information using "apropos" and "describe". For instance,
using (apropos 'concat) would have shown "concatenate", and then
(describe 'concatenate) might have given enough info to use it.

						- Marty Hall
------------------------------------------------------
····@aplcen.apl.jhu.edu, ···········@jhunix.bitnet, ..uunet!aplcen!hall
Artificial Intelligence Lab, AAI Corp, PO Box 126, Hunt Valley, MD 21030

(setf (need-p 'disclaimer) NIL)
From: ·········@cc.helsinki.fi
Subject: Re: Concatenate strings in common lisp. [really help without CltL]
Date: 
Message-ID: <1991Aug20.105453.1@cc.helsinki.fi>
In article <·····················@aplcen.apl.jhu.edu>, ····@aplcen.apl.jhu.edu (Marty Hall) writes:
> ······@cs.albany.edu (Tushar Saxena) writes:
>>I would like to know how to concatenate two strings in common lisp (KCL)
>>the way you do it in Franz Lisp using concat.
> 
> As the author knows by now, "concatenate" was the appropriate function.
> 
> It might be worth reminding those without a copy of CLtL (or _Common LISP
> the Reference_ or the Symbolics Document Examiner) handy that you can
> still get useful information using "apropos" and "describe". For instance,
> using (apropos 'concat) would have shown "concatenate", and then
> (describe 'concatenate) might have given enough info to use it.
> 
> 						- Marty Hall
> ------------------------------------------------------
> ····@aplcen.apl.jhu.edu, ···········@jhunix.bitnet, ..uunet!aplcen!hall
> Artificial Intelligence Lab, AAI Corp, PO Box 126, Hunt Valley, MD 21030
> 
> (setf (need-p 'disclaimer) NIL)

Concatenate is not perhaps one of those "well written" functions in the many
Common Lisp implementations. I would write something like:

(defun string-append (string1 string2 &rest strings)
 (declare (optimize (safety 0) (speed 3)) ;;; or safety 1 
	  (ftype (function (fixnum fixnum) fixnum) +)
	  (ftype (function (string) fixnum) length)
          (ftype (function (string fixnum) char))
 (let* ((l1 (length string1))
	(l2 (length string2))
	(len (+ l1 l2))
	(char-pointer len))
	
	(loop for string in strings do 
	       	(incf len (length string)))
	 
        (let ((res-string (make-string len)))
         (dotimes (index l1)
	   (setf (char res-string index) (char string1 index)))
     	 (dotimes (index l2)
	   (setf (char res-string (+ index l1)) (char string2 index)))
	 (loop for string in strings do 
	   (let ((strlen (length string)))
     	      (dotimes (index strlen)
	        (setf (char res-string (+ char-pointer index))
                      (char string index)))
	       (incf char-pointer strlen)))
         res-string))))) ;;; is there already enough )'s 
		
I don't test the code, but it would perhaps work with some modifications.

	                      	
     		
	
From: Barry Margolin
Subject: Re: Concatenate strings in common lisp. [really help without CltL]
Date: 
Message-ID: <1991Aug20.163649.6453@Think.COM>
In article <··················@cc.helsinki.fi> ·········@cc.helsinki.fi writes:
>Concatenate is not perhaps one of those "well written" functions in the many
>Common Lisp implementations. I would write something like:

In Sun CL 4.0 on a Sun-4, CONCATENATE is about 5 times faster than
your STRING-APPEND.  Sun CL also includes its own STRING-APPEND, which is
only slightly faster than CONCATENATE.

In Genera 8.1 on a Symbolics 3645, your STRING-APPEND is 20-90% faster than
CONCATENATE.  But the built-in STRING-APPEND is about 8 times faster than
yours.

The built-in functions can often take advantage of block transfer
instructions or do word-by-word copies instead of byte-by-byte copies.
-- 
Barry Margolin, Thinking Machines Corp.

······@think.com
{uunet,harvard}!think!barmar
From: Milt Epstein
Subject: Re: Concatenate strings in common lisp.
Date: 
Message-ID: <28A8344B.81E@ibma0.cs.uiuc.edu>
In <···@hilbert.albany.edu> ······@cs.albany.edu (Tushar Saxena) writes:

>I would like to know how to concatenate two strings in common lisp (KCL)
>the way you do it in Franz Lisp using concat.
>
>Thanks
>
>	-Tushar Saxena

Hmmm, checking out Steele's reference on Common Lisp, there is a
function CONCATENATE, which works on sequences.  It's syntax is

   (concatenate <result-type> &rest <sequences>)

So, I tried

   (concatenate 'string "abc" "def")

and both allegro common lisp and kyoto common lisp presented me with 

   "abcdef"

Hope this helps.

-- 
Milt Epstein
Department of Computer Science
University of Illinois
·······@cs.uiuc.edu