Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.4K Views
|
4 Replies
|
4 Total Likes
View groups...
Share
Share this post:

[collective thread] arbitrary WLDC example — Questions?

Most example codes in the WLDC are so well-chosen and instructive/didactic/educational/helpful that the one-liner is not accompanied by sufficient but concise or "none" explanation. And only on very rare occasions would we stumble over example code which we really "don't get" (the point/purpose/intention/reason d'etre/function) - basically these are examples which should have gotten improved code or better/more explanations in order to make the reader understand.

Maybe it is a good idea to question some arbitrary given example which you have come across while studying the WLDC? In a collective effort we could point out questionable examples (and comment on the post with the according Reply-button) and possibly suggest improvements to code or text. This thread is not primarily about reporting typos/errors/bugs but they could be part of the problem why we don't get the example, sometimes.

For easy reference, let's include the documentation reference URL of the function and also indicate the examples subsection where to find the referred example. I have bookmarked & memorized this thread URL for convenient access/future additions under:

https://tinyurl.com/wldcexample

POSTED BY: Raspi Rascal
4 Replies

Infix usage of Composition[]. Have you ever wondered what the difference between @ and @* is, when even the documentation shows that they have the same effect, see 'Different ways of entering compositions' in 'Properties & Relations', also 'Basic Examples'? Imho the documentation should show the opposite, the difference! It is true that in most instances the one can be replaced by the other so i always wonder (and the doc page wouldn't clarify).

However i found a useful example where you must use the Composition infix:

In[1]:= nx = {3, 2, 5, 3, 1};
ny = {1, 3, 2, 2};
Outer[Total@List, nx, ny] // Quiet(*doesn't return desired result*)

Out[3]= {{Total[List][3, 1], Total[List][3, 3], Total[List][3, 2], Total[List][3, 2]}, 
  {Total[List][2, 1], Total[List][2, 3], Total[List][2, 2], Total[List][2, 2]},
  {Total[List][5, 1], Total[List][5, 3], Total[List][5, 2], Total[List][5, 2]}, 
  {Total[List][3, 1], Total[List][3, 3], Total[List][3, 2], Total[List][3, 2]},
  {Total[List][1, 1], Total[List][1, 3], Total[List][1, 2], Total[List][1, 2]}}

In[4]:= Outer[Total@*List, nx, ny](*returns desired result*)

Out[4]= {{4, 6, 5, 5}, {3, 5, 4, 4}, {6, 8, 7, 7}, {4, 6, 5, 5}, {2, 4, 3, 3}}

Hope you found this tidbit yummy, thanks for looking!

POSTED BY: Raspi Rascal
POSTED BY: Raspi Rascal
POSTED BY: Kuba Podkalicki
POSTED BY: Raspi Rascal
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard