help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Designing interface of a simple elisp function


From: Henrik Motakef
Subject: Re: Designing interface of a simple elisp function
Date: 12 Oct 2002 18:15:39 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

gnuist006@hotmail.com (gnuist006) writes:

> Now this "car" does not apply to a string but to a list. On the other
> hand the arbitary length input applies to string. Does there exist
> string to list function? But even that also seems cheating. What is the
> most elegant way to write such a function so that it is also readible
> in use.

The map-functions work on sequences, not only lists. So, for example

  (mapcar 'identity "foo")

returns a list of three characters. An alternative would be

  (split-string "foo" "")

which gives a list of one-character strings.

> (b2d '101001)   is most desirable
> (b2d "101001")  is tolerable if this is the best that can be done

You can convert a symbol to a name with the symbol-name function,
i.e. (symbol-name 'foo) => "foo". Unfortunatly, this will not work
with '101001, because it really is the same as 101001 - numbers are
self-quoting, so for example (eq '0001 1) is t, as is (numberp '1).
You could use '\101001 however, or just accept a number instead of a
symbol or string.

Regards
Henrik


reply via email to

[Prev in Thread] Current Thread [Next in Thread]