Martin RUBEY wrote:
> This is quite what I wanted to do, only, I didn't think about letting the
> user decide wether a result should be kept or not. Hence, how do I write a
> function as the adjacency_matrixK(g) below, that keeps the information in
> g (!!!) also? That is,
>
> M : adjacency_matrix(g);
> N : adjacency_matrix(g);
if previously you defined
adjacency_matrix(r) := foo(r)
then do this:
adjacency_matrix(r):=MEMOAJ[r]
MEMOAJ[r]:= foo(r)
the first time foo(r) will be called, and the result stored in MEMOAJ[r].
The next time it will be looked up in the hash table MEMAJ.
RJF
>
> should compute the matrix exactly once. Well, this is a silly example, the
> point is: How can I write a (Lisp) function that remembers its result
> properly? Have a function "Create_Graph" that sets up a unique new symbol
> and store everything under this label? When I think about it, this sounds
> right, does it?
>
> Martin
>
>
>>b) Create functions which tell the program whether to keep the info into
>>the graph or not:
>>
>> M : adjacency_matrix(g);
>> M : adjacency_matrixK(g);
>>
>>The first could simply return the adj. matrix, while the second could
>>store it in your "graph" structure or in a hash table, or any way you
>>want.
>
>
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima