Linked Questions

0 votes
1 answer
5k 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 idea on ...
Gosere's user avatar
  • 357
1 vote
1 answer
2k views

For loops in Mathematica [duplicate]

I'm actually the first time using loops in Mathematica. For example, I have: For[i = 1, i <= n, i++, For[j = 1, j <= n, j++, ....] How it is possible now ...
Michael's user avatar
  • 11
0 votes
2 answers
984 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 ...
lara's user avatar
  • 1,028
1 vote
1 answer
277 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 ...
Manishearth's user avatar
6 votes
0 answers
182 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 ...
Verbeia's user avatar
  • 34.5k
2 votes
0 answers
118 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, ...
Aron's user avatar
  • 1,772
0 votes
0 answers
60 views

What techniques have you employed to avoid loop in Mathematica? [duplicate]

It appears to me that loop in mathematica is very slow (compared with matlab). Since many people still use mathematica to finish their work, there must be some techniques to bypass this problem. ...
Charles6's user avatar
554 votes
37 answers
134k 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 ...
604 votes
19 answers
158k 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 ...
117 votes
4 answers
29k views

Why should I avoid the For loop in Mathematica?

Some people advise against the use of For loops in Mathematica. Why? Should I heed this advice? What is wrong with For? What ...
Szabolcs's user avatar
  • 236k
39 votes
12 answers
3k 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 ...
Andrew's user avatar
  • 10.5k
60 votes
5 answers
7k 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 ...
faleichik's user avatar
  • 12.7k
22 votes
9 answers
6k 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 ...
Jonathan Gleason's user avatar
52 votes
2 answers
8k views

Scan vs. Map vs. Apply

I cannot understand the difference between Apply, Scan, and Map. I have tried to play with ...
MOON's user avatar
  • 3,886
9 votes
8 answers
3k 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 ...
Andrew's user avatar
  • 10.5k

15 30 50 per page
1
2 3 4 5
9