Can someone please tell me if there are other functions
such as explode and implode which can break an atom
into its individual characters thus creating new
atoms and then concatenating these new atoms to form
a single atom once again. I'm trying to use explode
and implode on my system, but have not been implemented.
Are there any other more common functions such as these ?
Thanks,
Alex
In article <··········@cville-srv.wam.umd.edu> ·····@wam.umd.edu (Alex Calingo) writes:
> Can someone please tell me if there are other functions
> such as explode and implode which can break an atom
> into its individual characters thus creating new
> atoms and then concatenating these new atoms to form
> a single atom once again. I'm trying to use explode
> and implode on my system, but have not been implemented.
> Are there any other more common functions such as these ?
Implode and explode are fairly old fashioned. While they let symbols to be
constructed using list operations, which may seem convienent, they are
rather expensive. I'd recommend doing something more direct like
(intern (concatenate 'string (symbol-name prefix) "-" (symbol-name thing)))
k
In article <··········@cville-srv.wam.umd.edu> ·····@wam.umd.edu (Alex Calingo) writes:
> Can someone please tell me if there are other functions
> such as explode and implode which can break an atom
> into its individual characters thus creating new
> atoms and then concatenating these new atoms to form
> a single atom once again. I'm trying to use explode
> and implode on my system, but have not been implemented.
> Are there any other more common functions such as these ?
Implode and explode are fairly old fashioned. While they let symbols to be
constructed using list operations, which may seem convienent, they are
rather expensive. I'd recommend doing something more direct like
(intern (concatenate 'string (symbol-name prefix) "-" (symbol-name thing)))
k
In article <··········@lace.colorado.edu> ········@pooh.uccs.edu (Brian T. Crowder) writes:
From: ········@pooh.uccs.edu (Brian T. Crowder)
Date: 14 Nov 1995 03:18:54 GMT
Alex Calingo (·····@wam.umd.edu) wrote:
: Can someone please tell me if there are other functions
: such as explode and implode
: Are there any other more common functions such as these ?
Assuming common lisp, there are lots of other better string
manipulation functions - eg concatenate, subseq.
Try these on for size :
(defun explode (symbol)
(coerce (symbol-name symbol) 'list))
I think this implementation is closer to the real definition.
(defun explode (symbol)
(map 'list #'(lambda (ch) (intern (string ch))) (string symbol)))
>(explode 'explode)
(E X P L O D E)
(defun implode (charlist)
(values (read-from-string (coerce charlist 'string))))
This version has the following interesting behavior
>(implode '(#\1 #\e #\1))
10.0
>(implode '(#\# #\. #\( #\e #\r #\r #\o #\r #\) ))
Error: ERROR [or a callee] requires more than zero arguments.
read-from-string is dangerous to use in this type of context.
(defun implode (list)
(values (intern (map 'string #'(lambda (ch) (char (string ch) 0)) list))))
>(implode (explode 'explode))
EXPLODE
--
-------------------------------------------------------------------------
The beatings will continue until morale improves.
E-mail: ········@culebra.uccs.edu
-------------------------------------------------------------------------
--
-jeff
······@avid.com