Den Mon, 17 Dec 2007 05:56:09 -0800 skrev livingcosmos.org:
[snip]
I am curious as to how exactly you choose the nick/handle/name you write
under. Do you do something like this?
(use-package :sb-md5)
(defvar *names* '("livingcosmos.org" "metaperl" "redick.metaperl.com"))
(defun choose-name (&optional (names *names*))
(let* ((len (length names))
(time (get-universal-time))
(index (reduce '+ (md5sum-string (princ-to-string time)))))
(elt names (mod index len))))
Cheers,
Maciej
On Dec 17, 11:42 am, Maciej Katafiasz <········@gmail.com> wrote:
> Den Mon, 17 Dec 2007 05:56:09 -0800 skrev livingcosmos.org:
>
> [snip]
>
> I am curious as to how exactly you choose the nick/handle/name you write
> under.
I use google's web api to post here. I think one browser has one nick
and another has another :)
> Do you do something like this?
>
no, no programming involved. I miss my days of Gnus though. Perhaps I
should get back into Sylpheed claws or something better than just web
posting. Sigh.
Den Mon, 17 Dec 2007 21:14:14 -0800 skrev livingcosmos.org:
>> Do you do something like this?
>>
> no, no programming involved. I miss my days of Gnus though. Perhaps I
> should get back into Sylpheed claws or something better than just web
> posting. Sigh.
That was a subtle poke at the randomness of it :). I feel your pain
though, I was very happy to find out my ISP carried a news server that
allowed me to post to c.l.l. Have you checked if yours doesn't?
Cheers,
Maciej
??>> no, no programming involved. I miss my days of Gnus though. Perhaps I
??>> should get back into Sylpheed claws or something better than just web
??>> posting. Sigh.
MK> That was a subtle poke at the randomness of it :). I feel your pain
MK> though, I was very happy to find out my ISP carried a news server that
MK> allowed me to post to c.l.l. Have you checked if yours doesn't?
even if he's doesn't there is news.sunsite.dk and plenty of other free.
On Dec 17, 5:56 am, "livingcosmos.org" <········@gmail.com> wrote:
> How can you generate the cartesian cross product of a list of
> sequences?
It's just called the Cartesian product.
How can you generate it? Well, for the binary case, you pair every
element in the first set, with every element in the second set, in
every possible way, and produce the set of these pairs.
Since you want this for sequences, you have to handle eight cases:
list X list -> list
list X vector -> list
vector X list -> list
vector X vector -> list
and the other four where the output is a vector.
A (binary) Cartesian product over lists only, list X list -> list,
can be done like this:
(defun cartesian (x y)
(loop for xi in x
appending (loop for yi in y
collecting (list xi yi))))
If you want to extend this to the N-ary Cartesian product, you can
rewrite the function above like this, and rename it:
(defun cartesian-binary (x y)
(loop for xi in x
appending (loop for yj in y
collecting
(cond
((and (listp xi) (listp yj)) (append xi
yj))
((listp xi) (append xi (list yj)))
((listp yj) (cons xi yj))
(t (list xi yj))))))
At the core are some cases which break open and re-combine tuples, as
necessary. This is slightly broken now, since now we can't have sets
of sets. This is due to the ambiguity of using lists as both sets and
tuples. (We could use vectors for tuples and lists for sets to fix the
problem).
But anyway, this gives us the ability to handle sets containing
tuples, which is important because the set containing the empty tuple
is the identity element:
(cartesian-binary '(()) '(1 2 3)) -> ((1) (2) (3))
and also
(cartesian-binary '(()) '((1) (2) (3))) -> ((1) (2) (3))
Scalar elements and 1-tuples are considered the same.
We can define the nullary Cartesian product---the Cartesian product
with no arguments---as producing the identity element.
And so we can now write CARTESIAN using REDUCE over CARTESIAN-BINARY,
using :INITIAL-VALUE to induce from identity:
(defun cartesian (&rest sets)
(reduce #'cartesian-binary lists :initial-value '(())))
There you go.