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

MathGroup Archive 2000

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

Search the Archive

Summary: List element manipulation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25467] Summary: List element manipulation
  • From: "Martin Rommel" <rommel at semitest.com>
  • Date: Sun, 1 Oct 2000 02:44:54 -0400 (EDT)
  • References: <8r19qf$hvt@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Thanks to the many helpful people that replied with their insight.
The straightforward fix to my problematic

> MapAt[Decrement, Range[116, 166, 8], -1]
>
>     Decrement::"rvalue": "164 is not a variable with a value, so its value
> cannot be changed."

is using a function # - 1& instead of Decrement (which is not a mathematical
function but instead listed under programming assignments in the help
browser)

MapAt[# - 1&, Range[116, 166, 8], -1]

This was suggested by the news group veterans David Park, Andrzej Kozlowski,
Hartmut Wolf and Allan Hayes.

Matt Johnson suggested an alternative using a rule (it is always interesting
to see things done differently)

Range[116, 166, 8] /. {h___, t_} -> {h, t - 1}

Special thanks to Andrzej Kozlowski for additonal explainations but the most
in depth coverage came from my compatriot Hartmut Wolf.

With hindsight I don't understand why I was so fixated on employing
Decrement.

Martin



  • Prev by Date: Re: I do not understand
  • Next by Date: Re: LegendreP & Gauss quad bug
  • Previous by thread: Re: How to solve the system of linear equations?
  • Next by thread: Re: Summary: List element manipulation