This works great. Thanks, Robert.
Now, how about a 'history' like function.
I know one can use 'save' and 'stringout' to write commands,
functions, etc to a file.
But, if one used a certain 'plot' command, or 'solve' command, it
would be nice to call it up again without
saving to a file, searching in the file, and then cutting and
pasting to get it back into the current session.
BTW, if this kind of thing is not appropriate for this mailing list,
please tell me, and I'll stop talking about such things.
I realize that there are more important things to fix and put into
maxima. I just thought that some (even mild) additions to the user
interface would be worth discussing.
-sen
On Wed, 6 Dec 2006, Robert Dodier wrote:
> On 12/6/06, sen1 at math.msu.edu <sen1 at math.msu.edu> wrote:
>
>> I would like to have tools such as grep available with some of the
>> built in maxima functions in interactive sessions.
>>
>> for instance, suppose I have a lot user defined functions, and some of
>> them have the characters "iter" in them.
>
> OK, here is something to look for functions with "FOO" in their names ...
>
> load (stringproc);
> sublist (map (op, functions), lambda ([e], ssearch ("FOO",string(e)) # false));
>
> Here is something slightly more general. This makes "|" an n-ary
> operator which is reminiscent of a Unix "|".
>
> load (stringproc);
> grep([L]):=if length(L) = 2
> then sublist(L[2],lambda([e],ssearch(L[1],e) # false))
> else buildq([a:L[1]],lambda([L2],grep(a,L2)));
> nary("|");
> "|"([L]) := block ([a : first(L)], for e in rest(L) do a : apply (e, [a]), a);
>
> e.g.
> grep ("foo", ["foo1", "foo2", "bar1", "bar2"]);
> => [foo1, foo2]
> grep ("foo");
> => lambda([L2], grep(foo, L2))
> aab(x) := 1; aac(x) := 2; aad(x) := 3; bbc(x) := 4; bbd(x) := 5;
> ccb(x) := 6; ccd(x) := 7;
> functions;
> => [grep([L]), "|"([L]), aab(x), aac(x), aad(x), bbc(x), bbd(x),
> ccb(x), ccd(x)]
> map (op, functions) | grep ("a");
> => [aab, aac, aad]
> map (op, functions) | grep ("a") | grep ("c");
> => [aac]
> map (op, functions) | grep ("ab") | lambda ([L], map (supcase, L));
> => [$AAB]
>
> (Dollar sign appears because function names are symbols, not strings;
> an intervening lambda([L], map(string, L)) would suppress the $ here.)
>
> I've kicked around ideas to make "pipeline"-like constructs in Maxima,
> but never settled on anything. A couple of issues for discussion:
> (1) The "|" defined above works on whole lists. "|" for lazy lists
> (i.e. elements don't appear until you ask for them) would be nice;
> it would make processing very long lists more efficient.
> Of course that requires a lazy list implementation, which Maxima
> lacks at the moment. (2) Each operator in the pipeline has to take
> a list as an argument, because some operators take away some
> elements; if every operator justs changes each element, without
> changing the number of elements, functions which take a single
> element as an argument could be pipeline operators. As it stands,
> such functions have to be wrapped in lambda([L], map(F, L)).
>
> On a related note, the notion of importing CL-PPCRE (a very
> powerful regex library) into Maxima has been floated at least once.
> Maxima already contains NREGEX, another regex library.
>
> Comments?
>
> HTH
> Robert Dodier
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
--
---------------------------------------------------------------------------
| Sheldon E. Newhouse | e-mail: sen1 at math.msu.edu |
| Mathematics Department | |
| Michigan State University | telephone: 517-355-9684 |
| E. Lansing, MI 48824-1027 USA | FAX: 517-432-1562 |
---------------------------------------------------------------------------