[Date Index]
[Thread Index]
[Author Index]
Re: extract elements from a list
*To*: mathgroup at smc.vnet.net
*Subject*: [mg2850] Re: extract elements from a list
*From*: NEWSMGR at selu.edu
*Date*: Wed, 27 Dec 1995 00:48:03 -0500
*Organization*: Southeastern Louisiana University
>Subject: Re: extract elements from a list
>From: koppel at omega.ee.lsu.edu (David M. Koppelman)
>Organization: Louisiana State University ECE Dept.
In article <4bg3ba$ob8 at dragonfly.wri.com> "cjkelly at bu.edu" <cjkelly at bu.edu> writes:
>
> I've been trying to extract elements from a list x={a,b,c,d,e...}
> then square each value and pair it up with the original unsquared value.
> These two values form a point (2Dim) and I then try to pair up each
> point with a given vertex of {5,25} and use Line[{{5,25},{a,a^2}}] to
> graph this thing.
>
> My main routine (reAlly kinda small)
> is...Do[n=x[[i]];Line[{{5,25},{n,n^2}}],{i,10,1}]
>
> When this is run nothing happens....
>
> in this case x={5,5.5,5.4,5.3,5.2...ect}
There are several problems with the code above. First, a negative step
should be used when iterating from 10 to 1. (Unless that was a typo.)
The "Line" function doesn't draw a line when evaluated. Instead,
"Line" is meaningful as an argument to "Graphics." Similarly,
evaluating "Graphics" does not result in anything being drawn; it
should be used as an argument to "Show" which will draw the stuff
described by "Graphics."
The following might do what you want:
Show[Graphics[Line[{{5,25},{#,#^2}}]&/@{5,5.5,5.4,5.3,5.2}]]
> I've been stuck for 2 weeks unable to get this to work and it is
> driving me crazy because it should be sooo easy.
One has not really experienced frustruation until one has worked
with computers.
__
/\ /\ /\
<> <> David M. Koppelman <>
<> koppel at gate.ee.lsu.edu <> 102 EE Building <>
<> (504)-388-5482 <> Louisiana State University <>
<> http://www.ee.lsu.edu/koppel <> Baton Rouge, La 70803 <>
~~ ~~ ~~
Prev by Date:
**Re: Mathematica as a programming language.**
Next by Date:
**Re: Programming**
Previous by thread:
**Re: extract elements from a list**
Next by thread:
**Re: extract elements from a list**
| |