Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #1833 > unrolled thread
| Started by | Sol Lederman <sol.lederman@gmail.com> |
|---|---|
| First post | 2011-04-22 09:41 +0000 |
| Last post | 2011-04-27 09:38 +0000 |
| Articles | 14 — 8 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
How to roll up multiple Line calls into a loop Sol Lederman <sol.lederman@gmail.com> - 2011-04-22 09:41 +0000
Re: How to roll up multiple Line calls into a loop Dan <dflatin@rcn.com> - 2011-04-23 11:50 +0000
Re: How to roll up multiple Line calls into a loop "Christopher O. Young" <cy56@comcast.net> - 2011-04-25 11:29 +0000
Re: How to roll up multiple Line calls into a loop Albert Retey <awnl@gmx-topmail.de> - 2011-04-23 11:51 +0000
Re: How to roll up multiple Line calls into a loop "Christopher O. Young" <cy56@comcast.net> - 2011-04-23 11:51 +0000
Re: How to roll up multiple Line calls into a loop Helen Read <readhpr@gmail.com> - 2011-04-23 11:51 +0000
Re: How to roll up multiple Line calls into a loop Peter Pein <petsie@dordos.net> - 2011-04-23 11:52 +0000
Re: How to roll up multiple Line calls into a loop roby <roby.nowak@gmail.com> - 2011-04-23 11:52 +0000
Re: How to roll up multiple Line calls into a loop Yves Klett <yves.klett@googlemail.com> - 2011-04-24 12:24 +0000
Short-cut for reiteration, via postfix usage of Table as pure "Christopher O. Young" <cy56@comcast.net> - 2011-04-25 11:27 +0000
Short-cut for reiteration, via postfix usage of Table as pure "Christopher O. Young" <cy56@comcast.net> - 2011-04-25 11:27 +0000
Re: Short-cut for reiteration, via postfix usage of Table as pure Peter Pein <petsie@dordos.net> - 2011-04-26 10:51 +0000
Re: Short-cut for reiteration, via postfix usage of Table as pure Peter Pein <petsie@dordos.net> - 2011-04-26 10:50 +0000
Re: Short-cut for reiteration. Concise, readable symbols and "Christopher O. Young" <cy56@comcast.net> - 2011-04-27 09:38 +0000
| From | Sol Lederman <sol.lederman@gmail.com> |
|---|---|
| Date | 2011-04-22 09:41 +0000 |
| Subject | How to roll up multiple Line calls into a loop |
| Message-ID | <iorih5$o6t$1@smc.vnet.net> |
Hi,
I'm new to Mathematica.
I have the following bit of graphics:
Graphics[{
Line[{{0, 10}, {1, 0}}],
Line[{{0, 9}, {2, 0}}],
Line[{{0, 8}, {3, 0}}],
Line[{{0, 7}, {4, 0}}],
Line[{{0, 6}, {5, 0}}],
Line[{{0, 5}, {6, 0}}],
Line[{{0, 4}, {7, 0}}],
Line[{{0, 3}, {8, 0}}],
Line[{{0, 2}, {9, 0}}],
Line[{{0, 1}, {10, 0}}],
}]
I want to simplify it to do some sort of iteration to compute the end points
of the lines. I can do this easily in a variety of procedural languages but
I haven't yet grokked how Mathematica would do this.
Would someone please show me the short way, I imagine using Table somehow?
Thanks.
Sol
[toc] | [next] | [standalone]
| From | Dan <dflatin@rcn.com> |
|---|---|
| Date | 2011-04-23 11:50 +0000 |
| Message-ID | <iouedm$6h6$1@smc.vnet.net> |
| In reply to | #1833 |
On Apr 22, 5:41 am, Sol Lederman <sol.leder...@gmail.com> wrote:
> Hi,
>
> I'm new to Mathematica.
>
> I have the following bit of graphics:
>
> Graphics[{
> Line[{{0, 10}, {1, 0}}],
> Line[{{0, 9}, {2, 0}}],
> Line[{{0, 8}, {3, 0}}],
> Line[{{0, 7}, {4, 0}}],
> Line[{{0, 6}, {5, 0}}],
> Line[{{0, 5}, {6, 0}}],
> Line[{{0, 4}, {7, 0}}],
> Line[{{0, 3}, {8, 0}}],
> Line[{{0, 2}, {9, 0}}],
> Line[{{0, 1}, {10, 0}}],
> }]
>
> I want to simplify it to do some sort of iteration to compute the end points
> of the lines. I can do this easily in a variety of procedural languages but
> I haven't yet grokked how Mathematica would do this.
>
> Would someone please show me the short way, I imagine using Table somehow?
>
> Thanks.
>
> Sol
Graphics[(Line[{{0,11-#},{#,0}}]&)/@Range[10]]
But let's take this appart a little. This short Mathematica expression
has a number of parts and it is worth looking at each of them.
Beginning at the right hand side, look at Range[10]
In[10]:= Range[10]
Out[10]= {1,2,3,4,5,6,7,8,9,10}
See how it can generate a sequence of numbers. This function is very
general, having the flexibility for creating almost any sort of
uniformly spaced set of values.
The next key element is the operator /@. This is shorthand for Map
which takes a function and applies it to each element of a list.
The function applied is a pure function, also called an anonymous
function in some languages:
(Line[{{0,11-#},{#,0}}]&)
The key syntactical elements are the Slot symbol, #, and the function
terminator, &. The outer parentheses are not needed but it is a good
practice to delimit your inline functions so it is obvious when
reading your code what the function is.
Dan
[toc] | [prev] | [next] | [standalone]
| From | "Christopher O. Young" <cy56@comcast.net> |
|---|---|
| Date | 2011-04-25 11:29 +0000 |
| Message-ID | <ip3lv0$r9r$1@smc.vnet.net> |
| In reply to | #1844 |
On 4/23/11 7:50 AM, in article iouedm$6h6$1@smc.vnet.net, "Dan"
<dflatin@rcn.com> wrote:
> Graphics[(Line[{{0,11-#},{#,0}}]&)/@Range[10]]
If we want to avoid typing out "Range", we can just define "R" as Range.
Then we can do this with:
Graphics[
Line[{{0, 10 - #}, {#, 0}}] & /@ 0~R~10
]
It looks like the ampersand will apply to the whole Line[ ] expression
without having to parenthesize it.
What I'd really like to do is have a more intuitive expression such as the
ellipsis character, =8A, for Range, and to be able to use it the way "+" and
"-" are used, without having to type the tildes on either side to show it's
an infix symbol.
At any rate, here it is with the ellipsis defined as Range:
\[Ellipsis] = Range
Graphics[
Line[{{0, 10 - #}, {#, 0}}] & /@ 0~\[Ellipsis]~10
]
[toc] | [prev] | [next] | [standalone]
| From | Albert Retey <awnl@gmx-topmail.de> |
|---|---|
| Date | 2011-04-23 11:51 +0000 |
| Message-ID | <iouefc$6io$1@smc.vnet.net> |
| In reply to | #1833 |
Am 22.04.2011 11:41, schrieb Sol Lederman:
> Hi,
>
> I'm new to Mathematica.
>
> I have the following bit of graphics:
>
> Graphics[{
> Line[{{0, 10}, {1, 0}}],
> Line[{{0, 9}, {2, 0}}],
> Line[{{0, 8}, {3, 0}}],
> Line[{{0, 7}, {4, 0}}],
> Line[{{0, 6}, {5, 0}}],
> Line[{{0, 5}, {6, 0}}],
> Line[{{0, 4}, {7, 0}}],
> Line[{{0, 3}, {8, 0}}],
> Line[{{0, 2}, {9, 0}}],
> Line[{{0, 1}, {10, 0}}],
> }]
>
>
> I want to simplify it to do some sort of iteration to compute the end points
> of the lines. I can do this easily in a variety of procedural languages but
> I haven't yet grokked how Mathematica would do this.
Well, you need to tell Mathematica how to do this...
> Would someone please show me the short way, I imagine using Table somehow?
... this is one way, as you imagined, Table seems to be an adequat
starting point:
Graphics[Table[Line[{{0, 11 - i}, {i, 0}}], {i, 10}]]
Here is something somewhat more elaborated:
Manipulate[
Graphics[
Line[Table[{{0, n - i + 1}, {i, 0}}, {i, n}]],
ImageSize -> {300,300}
],
{n, 5, 100}
]
note that Line will accept a list of line definitions as the argument,
which is somewhat more efficient when showing many lines. For graphics
within a manipulate you almost always want to set an explict ImageSize
or PlotRange.
hth,
albert
[toc] | [prev] | [next] | [standalone]
| From | "Christopher O. Young" <cy56@comcast.net> |
|---|---|
| Date | 2011-04-23 11:51 +0000 |
| Message-ID | <ioueg3$6kd$1@smc.vnet.net> |
| In reply to | #1833 |
On 4/22/11 5:41 AM, in article iorih5$o6t$1@smc.vnet.net, "Sol Lederman"
<sol.lederman@gmail.com> wrote:
> Hi,
>
> I'm new to Mathematica.
>
> I have the following bit of graphics:
>
> Graphics[{
> Line[{{0, 10}, {1, 0}}],
> Line[{{0, 9}, {2, 0}}],
> Line[{{0, 8}, {3, 0}}],
> Line[{{0, 7}, {4, 0}}],
> Line[{{0, 6}, {5, 0}}],
> Line[{{0, 5}, {6, 0}}],
> Line[{{0, 4}, {7, 0}}],
> Line[{{0, 3}, {8, 0}}],
> Line[{{0, 2}, {9, 0}}],
> Line[{{0, 1}, {10, 0}}],
> }]
>
>
> I want to simplify it to do some sort of iteration to compute the end points
> of the lines. I can do this easily in a variety of procedural languages but
> I haven't yet grokked how Mathematica would do this.
>
>
> Would someone please show me the short way, I imagine using Table somehow?
The following will do it:
Graphics[
Table[Line[{{0, 10 - k + 1}, {k, 0}}], {k, 1, 10}]
]
I keep wishing there were some way to do this using a replacement rule or an
iteration specifier tacked on to the end of the line.
[toc] | [prev] | [next] | [standalone]
| From | Helen Read <readhpr@gmail.com> |
|---|---|
| Date | 2011-04-23 11:51 +0000 |
| Message-ID | <iouege$6ko$1@smc.vnet.net> |
| In reply to | #1833 |
On 4/22/2011 5:41 AM, Sol Lederman wrote:
> Hi,
>
> I'm new to Mathematica.
>
> I have the following bit of graphics:
>
> Graphics[{
> Line[{{0, 10}, {1, 0}}],
> Line[{{0, 9}, {2, 0}}],
> Line[{{0, 8}, {3, 0}}],
> Line[{{0, 7}, {4, 0}}],
> Line[{{0, 6}, {5, 0}}],
> Line[{{0, 5}, {6, 0}}],
> Line[{{0, 4}, {7, 0}}],
> Line[{{0, 3}, {8, 0}}],
> Line[{{0, 2}, {9, 0}}],
> Line[{{0, 1}, {10, 0}}],
> }]
>
>
> I want to simplify it to do some sort of iteration to compute the end points
> of the lines. I can do this easily in a variety of procedural languages but
> I haven't yet grokked how Mathematica would do this.
>
>
> Would someone please show me the short way, I imagine using Table somehow?
lines = Table[{{0, 11 - n}, {n, 0}}, {n, 10}];
Graphics[Line[lines]]
--
Helen Read
University of Vermont
[toc] | [prev] | [next] | [standalone]
| From | Peter Pein <petsie@dordos.net> |
|---|---|
| Date | 2011-04-23 11:52 +0000 |
| Message-ID | <iouehs$6n9$1@smc.vnet.net> |
| In reply to | #1833 |
Am 22.04.2011 11:41, schrieb Sol Lederman:
> Hi,
>
> I'm new to Mathematica.
>
> I have the following bit of graphics:
>
> Graphics[{
> Line[{{0, 10}, {1, 0}}],
> Line[{{0, 9}, {2, 0}}],
> Line[{{0, 8}, {3, 0}}],
> Line[{{0, 7}, {4, 0}}],
> Line[{{0, 6}, {5, 0}}],
> Line[{{0, 5}, {6, 0}}],
> Line[{{0, 4}, {7, 0}}],
> Line[{{0, 3}, {8, 0}}],
> Line[{{0, 2}, {9, 0}}],
> Line[{{0, 1}, {10, 0}}],
> }]
>
>
> I want to simplify it to do some sort of iteration to compute the end points
> of the lines. I can do this easily in a variety of procedural languages but
> I haven't yet grokked how Mathematica would do this.
>
>
> Would someone please show me the short way, I imagine using Table somehow?
>
>
> Thanks.
>
>
> Sol
Do you think of sth. like:
With[{n = 10},
Table[Line[{{0, n - k}, {k + 1, 0}}], {k, 0, n - 1}] // Graphics]
?
[toc] | [prev] | [next] | [standalone]
| From | roby <roby.nowak@gmail.com> |
|---|---|
| Date | 2011-04-23 11:52 +0000 |
| Message-ID | <iouei7$6nb$1@smc.vnet.net> |
| In reply to | #1833 |
On 22 Apr., 11:41, Sol Lederman <sol.leder...@gmail.com> wrote:
> Hi,
>
> I'm new to Mathematica.
>
> I have the following bit of graphics:
>
> Graphics[{
> Line[{{0, 10}, {1, 0}}],
> Line[{{0, 9}, {2, 0}}],
> Line[{{0, 8}, {3, 0}}],
> Line[{{0, 7}, {4, 0}}],
> Line[{{0, 6}, {5, 0}}],
> Line[{{0, 5}, {6, 0}}],
> Line[{{0, 4}, {7, 0}}],
> Line[{{0, 3}, {8, 0}}],
> Line[{{0, 2}, {9, 0}}],
> Line[{{0, 1}, {10, 0}}],
> }]
>
> I want to simplify it to do some sort of iteration to compute the end points
> of the lines. I can do this easily in a variety of procedural languages but
> I haven't yet grokked how Mathematica would do this.
>
> Would someone please show me the short way, I imagine using Table somehow?
>
> Thanks.
>
> Sol
first note that the very last "," should be removed.
then the following code should do what you want
In[17]:= Graphics[{Line[{{0, 10}, {1, 0}}], Line[{{0, 9}, {2, 0}}],
Line[{{0, 8}, {3, 0}}], Line[{{0, 7}, {4, 0}}],
Line[{{0, 6}, {5, 0}}], Line[{{0, 5}, {6, 0}}],
Line[{{0, 4}, {7, 0}}], Line[{{0, 3}, {8, 0}}],
Line[{{0, 2}, {9, 0}}], Line[{{0, 1}, {10, 0}}]}] //
Cases[#, Line[{_, l_}] -> l, \[Infinity]] &
Out[17]= {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {8,
0}, {9, 0}, {10, 0}}
Cheers Robert
[toc] | [prev] | [next] | [standalone]
| From | Yves Klett <yves.klett@googlemail.com> |
|---|---|
| Date | 2011-04-24 12:24 +0000 |
| Message-ID | <ip14qm$ged$1@smc.vnet.net> |
| In reply to | #1833 |
Hi,
or as an excercise in Part (although the Cases approach is more versatile):
g = Graphics[{Line[{{0, 10}, {1, 0}}], Line[{{0, 9}, {2, 0}}],
Line[{{0, 8}, {3, 0}}], Line[{{0, 7}, {4, 0}}],
Line[{{0, 6}, {5, 0}}], Line[{{0, 5}, {6, 0}}],
Line[{{0, 4}, {7, 0}}], Line[{{0, 3}, {8, 0}}],
Line[{{0, 2}, {9, 0}}], Line[{{0, 1}, {10, 0}}]}];
g[[1, All, 1, -1]]
Out[3]= {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {8,
0}, {9, 0}, {10, 0}}
Regards,
Yves
Am 22.04.2011 11:41, schrieb Sol Lederman:
> Hi,
>
> I'm new to Mathematica.
>
> I have the following bit of graphics:
>
> Graphics[{
> Line[{{0, 10}, {1, 0}}],
> Line[{{0, 9}, {2, 0}}],
> Line[{{0, 8}, {3, 0}}],
> Line[{{0, 7}, {4, 0}}],
> Line[{{0, 6}, {5, 0}}],
> Line[{{0, 5}, {6, 0}}],
> Line[{{0, 4}, {7, 0}}],
> Line[{{0, 3}, {8, 0}}],
> Line[{{0, 2}, {9, 0}}],
> Line[{{0, 1}, {10, 0}}],
> }]
>
>
> I want to simplify it to do some sort of iteration to compute the end points
> of the lines. I can do this easily in a variety of procedural languages but
> I haven't yet grokked how Mathematica would do this.
>
>
> Would someone please show me the short way, I imagine using Table somehow?
>
>
> Thanks.
>
>
> Sol
[toc] | [prev] | [next] | [standalone]
| From | "Christopher O. Young" <cy56@comcast.net> |
|---|---|
| Date | 2011-04-25 11:27 +0000 |
| Subject | Short-cut for reiteration, via postfix usage of Table as pure |
| Message-ID | <ip3lrg$r6p$1@smc.vnet.net> |
| In reply to | #1868 |
I get a little tired of the excess typing involved with using Table for
simple reiteration of functions with a parameter list. Since Mathematica
doesn't seem to use "T" for anything, it's handy to just re-define this to
mean Table. Then use a postfix call with a "#" as a slot for the argument
and an ampersand "&" at the end to indicate a pure function. See
ref/Function in the Mathematica Help for details.
T = Table;
Graphics[
Line[{{0, 10 - k}, {k, 0}}] // T[#, {k, 0, 9}] &
]
>> I have the following bit of graphics:
>>
>> Graphics[{
>> Line[{{0, 10}, {1, 0}}],
>> Line[{{0, 9}, {2, 0}}],
>> Line[{{0, 8}, {3, 0}}],
>> Line[{{0, 7}, {4, 0}}],
>> Line[{{0, 6}, {5, 0}}],
>> Line[{{0, 5}, {6, 0}}],
>> Line[{{0, 4}, {7, 0}}],
>> Line[{{0, 3}, {8, 0}}],
>> Line[{{0, 2}, {9, 0}}],
>> Line[{{0, 1}, {10, 0}}],
>> }]
>>
>>
>> I want to simplify it to do some sort of iteration to compute the end points
>> of the lines. I can do this easily in a variety of procedural languages but
>> I haven't yet grokked how Mathematica would do this.
[toc] | [prev] | [next] | [standalone]
| From | "Christopher O. Young" <cy56@comcast.net> |
|---|---|
| Date | 2011-04-25 11:27 +0000 |
| Subject | Short-cut for reiteration, via postfix usage of Table as pure |
| Message-ID | <ip3lrr$r76$1@smc.vnet.net> |
| In reply to | #1868 |
Infix notation saves another keystroke and seems a little more intuitive to
me:
Graphics[
Line[{{0, 10 - k}, {k, 0}}] // #~Table~{k, 0, 9} &
]
Or, using the definition (to be put in the initialization file)
T = Table;
we have:
Graphics[
Line[{{0, 10 - k}, {k, 0}}] // #~T~{k, 0, 9} &
]
We can read this as "lines going from {0, 10 - k} to {k, 0} where k goes
from 0 to 9".
In the case of Line[ ], which accepts a list of points, we can shorten
things even more, to,
Graphics[
Line[{{0, 10 - k}, {k, 0}}~Table~{k, 0, 9}]
]
This is with the standard infix notation involving the tilde, "~".
With "T" defined as Table, we've got things down to a reasonable number of
keystrokes:
Graphics[
Line[{{0, 10 - k}, {k, 0}}~T~{k, 0, 9}]
]
>> I have the following bit of graphics:
>>
>> Graphics[{
>> Line[{{0, 10}, {1, 0}}],
>> Line[{{0, 9}, {2, 0}}],
>> Line[{{0, 8}, {3, 0}}],
>> Line[{{0, 7}, {4, 0}}],
>> Line[{{0, 6}, {5, 0}}],
>> Line[{{0, 5}, {6, 0}}],
>> Line[{{0, 4}, {7, 0}}],
>> Line[{{0, 3}, {8, 0}}],
>> Line[{{0, 2}, {9, 0}}],
>> Line[{{0, 1}, {10, 0}}],
>> }]
>>
>>
>> I want to simplify it to do some sort of iteration to compute the end points
>> of the lines. I can do this easily in a variety of procedural languages but
>> I haven't yet grokked how Mathematica would do this.
[toc] | [prev] | [next] | [standalone]
| From | Peter Pein <petsie@dordos.net> |
|---|---|
| Date | 2011-04-26 10:51 +0000 |
| Subject | Re: Short-cut for reiteration, via postfix usage of Table as pure |
| Message-ID | <ip682q$bmk$1@smc.vnet.net> |
| In reply to | #1873 |
sorry, I forgot to append:
G = Graphics; L = Line; T = Table;
G[L[{{0,10-k},{k,0}}~T~{k,0,9}]]
[toc] | [prev] | [next] | [standalone]
| From | Peter Pein <petsie@dordos.net> |
|---|---|
| Date | 2011-04-26 10:50 +0000 |
| Subject | Re: Short-cut for reiteration, via postfix usage of Table as pure |
| Message-ID | <ip682f$bmc$1@smc.vnet.net> |
| In reply to | #1873 |
I do not want to offend you.
Is this a contest laziness vs. readability?
There are options for some functions as strings like "AlternatingSigns",
"ExtrapolatingOscillatory" and others where Ctrl-K does not help and
"Table" is too complicated????
shaking the head,
Peter
Am 25.04.2011 13:27, schrieb Christopher O. Young:
> Infix notation saves another keystroke and seems a little more intuitive to
> me:
> Graphics[
> Line[{{0, 10 - k}, {k, 0}}] // #~Table~{k, 0, 9}&
> ]
>
> Or, using the definition (to be put in the initialization file)
>
> T = Table;
>
> we have:
>
> Graphics[
> Line[{{0, 10 - k}, {k, 0}}] // #~T~{k, 0, 9}&
> ]
>
> We can read this as "lines going from {0, 10 - k} to {k, 0} where k goes
> from 0 to 9".
>
> In the case of Line[ ], which accepts a list of points, we can shorten
> things even more, to,
>
> Graphics[
> Line[{{0, 10 - k}, {k, 0}}~Table~{k, 0, 9}]
> ]
>
> This is with the standard infix notation involving the tilde, "~".
>
> With "T" defined as Table, we've got things down to a reasonable number of
> keystrokes:
>
> Graphics[
> Line[{{0, 10 - k}, {k, 0}}~T~{k, 0, 9}]
> ]
>
>>> I have the following bit of graphics:
>>>
>>> Graphics[{
>>> Line[{{0, 10}, {1, 0}}],
>>> Line[{{0, 9}, {2, 0}}],
>>> Line[{{0, 8}, {3, 0}}],
>>> Line[{{0, 7}, {4, 0}}],
>>> Line[{{0, 6}, {5, 0}}],
>>> Line[{{0, 5}, {6, 0}}],
>>> Line[{{0, 4}, {7, 0}}],
>>> Line[{{0, 3}, {8, 0}}],
>>> Line[{{0, 2}, {9, 0}}],
>>> Line[{{0, 1}, {10, 0}}],
>>> }]
>>>
>>>
>>> I want to simplify it to do some sort of iteration to compute the end points
>>> of the lines. I can do this easily in a variety of procedural languages but
>>> I haven't yet grokked how Mathematica would do this.
>
>
[toc] | [prev] | [next] | [standalone]
| From | "Christopher O. Young" <cy56@comcast.net> |
|---|---|
| Date | 2011-04-27 09:38 +0000 |
| Subject | Re: Short-cut for reiteration. Concise, readable symbols and |
| Message-ID | <ip8o6i$pgu$1@smc.vnet.net> |
| In reply to | #1889 |
On 4/26/11 6:50 AM, in article ip682f$bmc$1@smc.vnet.net, "Peter Pein"
<petsie@dordos.net> wrote:
> I do not want to offend you.
>
> Is this a contest laziness vs. readability?
>
> There are options for some functions as strings like "AlternatingSigns",
> "ExtrapolatingOscillatory" and others where Ctrl-K does not help and
> "Table" is too complicated????
>
> shaking the head,
> Peter
I can't dig up the books right now, but isn't it long-standing usage in math
texts to be able to append a parameter list? E.g.,
(1-t)[0 k] + t[10-k 0], k in {0, =8A, 10}
At any rate, that certainly seems like intuitive and concise notation to me.
I'm just trying to come close to that in Mathematica. It does seem "verbose"
if I have to use "Table" every time I do something as routine as the above.
There should be a syntax as short as the above example.
But I'll settle for
Graphics[Line[{{0, k}, {10 - k, 0}}~Table~{k, 0, 10}]]
Or
Line[{{0, k}, {10 - k, 0}}~Table~{k, 0, 10}] // Graphics
This comes closer to how I think about drawing a line.
I appreciate the shortcuts Mathematica provides, more because I find the
code cleaner and easier to follow if there are concise syntactical forms for
everyday, simple, routine situations such as the above notation for
parameter lists.
Having to use "Table" makes the code look unnecessarily cluttered, it seems
to me. There should be an ellipsis and a convention like the above in these
cases.
How can Mathematica become a popular tool for high school students, and most
college students, if they have to use cluttered, verbose code for everyday
routine expressions?
Another example: Mathematica should accept vectors in column format, not
just in list format or in row format. This would make linear algebra coding
about 100 times more readable.
I admire Michael Trott's abilities, but wading through the unformatted,
uncommented, tightly packed code of his introductory chapter just about
prevented me from picking up his Guide Books for months. It turns out that
it's mostly very concise string processing, but it took hours of formatting
and trying things out to see what he was doing.
Later on, he has in-depth discussions of Mathematica's structure that are a
big help for practical purposes, but you wouldn't guess it from the start of
his "Programming" Guide Book.
I suppose to experienced Mathematica programmers this sort of thing becomes
more natural. But it shouldn't take years to transfer from other forms of
programming to Mathematica programming. And it shouldn't take years of
training to grasp the mathematical meaning behind a page of Mathematica
code.`
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web