From: Robert D. <rob...@us...> - 2024-08-19 20:59:16
|
--- **[bugs:#4350] arrayinfo complains "not an array" when supplied a Lisp array or hash table** **Status:** open **Group:** None **Labels:** arrayinfo **Created:** Mon Aug 19, 2024 08:59 PM UTC by Robert Dodier **Last Updated:** Mon Aug 19, 2024 08:59 PM UTC **Owner:** nobody `arrayinfo` complains "not an array" when its argument is a Lisp array or Lisp hash table. However, when its argument is a symbol which has the Lisp array or hash table bound to it, then `arrayinfo` knows what to do. ``` (%i33) aa: make_array (any, 4); (%o33) {Lisp Array: #(NIL NIL NIL NIL)} (%i34) arrayinfo (aa); (%o34) [declared, 1, [3]] (%i35) apply (arrayinfo, [aa]); arrayinfo: {Lisp Array: #(NIL NIL NIL NIL)} is not an array. -- an error. To debug this try: debugmode(true); (%i36) hh: make_array (hashed, 1); (%o36) {Lisp Array: #<HASH-TABLE :TEST EQUAL :COUNT 1 {1004C322F3}>} (%i37) hh["foo"]: "bar"; (%o37) bar (%i38) arrayinfo (hh); (%o38) [hash_table, 1, foo] (%i39) apply (arrayinfo, [hh]); arrayinfo: {Lisp Array: #<HASH-TABLE :TEST EQUAL :COUNT 2 {1004C322F3}>} is not an array. -- an error. To debug this try: debugmode(true); ``` I bumped into this problem in the following context. I have a list of arrays, and I'm trying to call `arrayinfo` on each one. %o41 fails because getting the value of `L[1]` would require calling MEVAL, which, I'm happy to report, `arrayinfo` doesn't call. OK so far. The standard workaround is to call `apply(foo, [...])` for an argument-quoting function `foo`. But that doesn't work either, for `arrayinfo`: ``` (%i40) L: [aa]; (%o40) [{Lisp Array: #(NIL NIL NIL NIL)}] (%i41) arrayinfo (L[1]); arrayinfo: L is not an array. 1 -- an error. To debug this try: debugmode(true); (%i42) apply (arrayinfo, [L[1]]); arrayinfo: {Lisp Array: #(NIL NIL NIL NIL)} is not an array. -- an error. To debug this try: debugmode(true); ``` The fix is just to handle Lisp array and hash table values in addition to symbols. --- Sent from sourceforge.net because max...@li... is subscribed to https://sourceforge.net/p/maxima/bugs/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/maxima/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |