-1

(Edit: Sorry, this question does not have an actionable question. I've subsequently learned that posts to StackExchange must have one. I've tried to delete the question, but could not.)

There is a discussion here about why one shouldn't assign a variable to an Iconized form: Stack Exchange 2018: How use Iconize object assigned to a variable (Mathematica 11.3)?

There are some similarities to this common misstep by beginners:

matrix = RandomInteger[10 {-1, 1}, {3, 3}] // MatrixForm
matrix.matrix
Det[matrix]

Wouldn't it be useful if Iconize and MatrixForm and others acted like Echo and returned their result when used in an evaluated expression? And, beginners would not fall into that particular trap.

For example:

f[n_] := <|
  "list" -> Iconize[RandomReal[{0, 1}, n], 
    "List of Length " <> ToString[n]], "n" -> n|>

and then

res = f[10^6] (*tidy output*)
res["list"] (*looks fine*)
Mean[res["list"]] (*sigh*)

It would be handy to have that last expression return something close to 0.5.

Craig Carter
  • 4,416
  • 16
  • 28
  • 1
    Is there a question here? – Jason B. Aug 07 '22 at 18:06
  • Does there need to be a question? I thought this was a forum for exchange of ideas as well as questions. I must be looking in the wrong place then. Here’s a question, is there a good reason why Det[MatrixForm[mat]] can’t be software engineered to do something arguably sensible? The downvote and close is a bit harsh for this discussion? – Craig Carter Aug 07 '22 at 20:02
  • 1
    I did not downvote so I can't comment on that. There does need to be a question, this site is for Q&A not a general forum. "How can I make a version of Iconize that does XXX?" would be on-topic. – Jason B. Aug 07 '22 at 21:15
  • OK, I tried to delete the question but was disallowed. – Craig Carter Aug 08 '22 at 05:32

1 Answers1

2
$Version

(* "13.1.0 for Mac OS X x86 (64-bit) (June 16, 2022)" *)

Clear["Global`*"]

f[n_Integer?Positive] := 
 Iconize[RandomReal[{0, 1}, n], StringForm["List of Length ``", n]]

data = f[100]

enter image description here

As shown in the documentation, the list is the first element of data; consequently, the Mean is

data // First // Mean

(* 0.537824 *)

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
  • Yes, but… wouldn’t it be a convenience and produce more readable code to have Iconize be “transparent”? – Craig Carter Aug 07 '22 at 20:03
  • @CraigCarter perhaps it would, but perhaps that could lead to weird behavior and would almost certainly be complicated and prone to errors. In any case, yours does not seem to be an actionable question, but rather a proposal to bring up to Wolfram Support. – MarcoB Aug 08 '22 at 00:31