Linked Questions

0
votes
1answer
883 views

Loops and subroutines [duplicate]

Possible Duplicate: Alternatives to procedural loops and iterating over lists in Mathematica I am new to Mathematica and not familiar with functional programming. In particular, I have no ...
0
votes
2answers
166 views

Seeking faster method than using Table and If together [duplicate]

See the example below. Is there any way to make this execute much faster and still get the same output ? I have read Conditionals slower than operators? but it didn't really help me as I can't seem to ...
1
vote
1answer
139 views

How should I go about writing more functional and list based code? [duplicate]

I've heard that Mathematica is usually faster when the code is list-based and/or uses a functional paradigm. I'm still working on getting the hang of this; there are a lot of ...
6
votes
0answers
114 views

What are some general strategies to avoid using For loops? [duplicate]

Possible Duplicate: Iterating over lists in Mathematica While there are some cases where a For loop might be reasonable, it's a general mantra – one I ...
2
votes
0answers
103 views

Want explanation of when different looping constructs are appropriate [duplicate]

For example when would you use a Do loop over a For loop? For which tasks would you use Map, ...
0
votes
0answers
55 views

For loop efficiency [duplicate]

What is a more efficient way of solving this problem? By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. ...
263
votes
12answers
45k views

Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
135
votes
19answers
10k views

What are the most common pitfalls awaiting new users?

As you may already know, Mathematica is a wonderful piece of software. However, it has a few characteristics that tend to confuse new (and sometimes not-so-new) users. That can be clearly seen from ...
27
votes
12answers
1k views

Map a function across a list conditionally

It seems that this is a really basic question, and I feel that the answer should be obvious to me. However, I am not seeing. Can you please help me? Thanks. Suppose I have a list of data ...
15
votes
7answers
1k views

How do I check if any element in a list is positive?

As a simple example of what I would like to do, suppose I have a list a of all real numbers. I would like to perform a simple check to see if some element of ...
25
votes
5answers
2k views

Are there any cases when For[] loops are reasonable?

To my mind the only reason for the existence of For[] loops in Mathematica is to allow new users with some experience in procedural programming languages to write ...
12
votes
4answers
280 views

The gap between MapAt and ReplacePart for 2D data tables with headers

Consider a relational table derived from survey data, where each column ("001-01" ...) represents a responder and each row (...
2
votes
6answers
669 views

Selecting elements from a list one by one

I have an list: l = {{4,5},{7,8},{9,5},{3,2},{1,2},{13,12}}. I want to take the elements in the list in the sequential order. For example the first element in ...
5
votes
3answers
238 views

First evaluation fails

I am fairly new to Mathematica (version 7), so please bear with me... I have duplicated, in Mathematica, a program that I originally wrote in C (it generates OEIS sequence A191837). The problem is ...
3
votes
7answers
379 views

Finding the midpoints of an ordered list of numbers

Suppose that I have an ordered list of numbers. The numbers in the list may be evenly spaced, but they may not be. Here are two examples, list1 and ...

15 30 50 per page