Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1997
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: list manipulation problem (or: a usefull dumb question?)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg9113] Re: list manipulation problem (or: a usefull dumb question?)
  • From: weber at math.uni-bonn.de (Matthias Weber)
  • Date: Mon, 13 Oct 1997 23:33:25 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

In article <61hqst$d5n at smc.vnet.net>, Teemu Vesanen <Teemu.Vesanen at sci.fi>
wrote:

> I have a list like=20
> {{a, b, c}, {d, e, f}, {g, h, i}}
> I need to delete the third term of each sublist.
> In other words how do I make the list look like
> {{a, b}, {d, e}, {g, h}}
>

yourList={{a, b, c}, {d, e, f}, {g, h, i}};
Map[Drop[#, -1] &, yourList]

This is a typical example for the momentary thread about
usefull dumb questions.

A beginner has barely chance to figure this out, because it combines
two usefull concepts of Mathematica, Map and pure functions, the
latter having that sort of notation which terrifies beginners.

The best way to understand this is to ask oneself what one really
wants: A certain operation applied to a list
 (at a certain level -- but fortunately this does not show up here).
Map is the Mmma function which applies an function to a list, so
we only have to understand how wo write down a "function".
This is done by specifying a "pure function" (never forget the "&")
with argument "#".

So, what would be a good notation for this sort of operation be
instead of this mixture of weird symbols? I have no clue. 
One possibility would be a teachable version of Mathematica where
you can precisely say:

I have a list like
 {{a, b, c}, {d, e, f}, {g, h, i}}
which I want to become
 {{a, b}, {d, e}, {g, h}}

That would be cute.


Matthias Weber


  • Prev by Date: Re: RE: Re: Not so Useful Dumb User Questions
  • Next by Date: Re: wierd Log[0] *0 result
  • Previous by thread: announcement: new Plane Tiling package
  • Next by thread: Spellchecker?