How to find out runtime version of Maxima? (confused by new format of eigenvectors() in 5.19.2)



On Wed, Sep 16, 2009 at 19:54, Robert Dodier <robert.dodier at gmail.com> wrote:
> On 9/16/09, Alexander Shulgin <alex.shulgin at gmail.com> wrote:
>
>> maxima_version() :=
>> ? map(parse_string, tokens(?\*autoconf\-version\*, 'digitcharp));
>
> Maybe this can be simplified somewhat.
>
> split (?\*autoconf\-version\*, ".");
> ?=> ["5","19","2"]
>
> Note that the result of split is a list of strings.
> Incidentally it's not guaranteed that each element is just
> a number --- there have been (and there continue to be)
> version numbers which are numbers & letters combined.
>
>> version_compare(v1, v2) := block(
>> ? [len1: length(v1), len2: length(v2), v, i, cmp: 0],
>> ? if len2 > len1 then v1: append(v1, makelist(0, i, 1, len2 - len1)),
>> ? if len1 > len2 then v2: append(v2, makelist(0, i, 1, len1 - len2)),
>> ? v: v1 - v2,
>> ? i: 1,
>> ? while i <= length(v) and cmp = 0 do
>> ? ? (cmp: v[i],
>> ? ? ?i: i + 1),
>> ? cmp);
>>
>
> A custom comparison function isn't necessary.
> orderlessp does the right thing with lists.
>
> orderlessp (["5", "19", "1"], ["5", "19", "2"]);
> ?=> true

Oh, that's enlightening :)

I think it's fair to assume that letters can only come after the last
version number (e.g. "5.19.2a", but not "5.19a.1") and that letters
can not come after a period char.  Also, it should be guaranteed that
letters are taken into account in the lexicographical order.

Here's an updated code:

version_parse(v) := block(
  [tok: split(v, ".")],
  append(map(lambda([t], parse_string(tokens(t, 'digitcharp)[1])), tok),
    tokens(last(tok), 'alphacharp)));

version_lessp(v1, v2) :=
  orderlessp(version_parse(v1), version_parse(v2));

version_parse(v) := block(
  [tok: split(v, ".")],
  append(map(lambda([t], parse_string(tokens(t, 'digitcharp)[1])), tok),
    tokens(last(tok), 'alphacharp))),

version_lessp("5.19.2", "5.19.2a");
true

version_lessp("5.19a", "5.19.99");
false

etc.

I'd rather see it as a function built into maxima (with test suite).
So that if releaser decides to use some keen version number, the
problems are caught before the release is done and users made unhappy.
;)

--
Regards,
Alex