Linked Questions

6 votes
5 answers

Native function that gives sequential sub-sequences of a list? [duplicate]

I am very surprised not to find this function in the help (or in other questions on this site, which come close) Is there a Mathematica function f such that ...
user2686410's user avatar
2 votes
4 answers

Partition list into sublists of decreasing length [duplicate]

For example, I would like to partition {1,2,3,4,5} into {1} {1,2} {1,2,3} {1,2,3,4} {1,2,3,4,5} with just one line of code. ...
Alejandro Braun's user avatar
4 votes
2 answers

Calculate Cumulative Mean and Standard Deviation of a list without FOR loops [duplicate]

I have a simple list mylist={x_1,x_2,...,x_N};. Now I want to map a function over this list, e.g. the Mean and StandardDeviation functions, so that it will give me ...
Minh N's user avatar
  • 141
79 votes
8 answers

Partitioning with varying partition size

How can I partition a list into partitions whose sizes vary? The length of the $k$'th partition is a function $f(k)$. For example: if $l = \{1, 2, 3, 4, 5, 6\}$ and $f(k) = k$. Then the partitioning ...
sjdh's user avatar
  • 7,777
15 votes
5 answers

How to sum over a List

list = {11.5575, 11.397, 5.52734, 4.0878, 2.54815, 1.86652, 2.55028, 2.14952, 1.6242, 1.34117} I have a list of numbers. How do I make a function that creates a ...
olliepower's user avatar
  • 2,254
16 votes
2 answers

Finding all partitions of a set

I'm looking for straightforward way to find all the partitions of a set. IntegerPartitions seems to provide a useful start. But then things get a bit complicated. ...
DavidC's user avatar
  • 16.7k
8 votes
3 answers

Finding all sublists or substrings of a given list/string

Given a list or string, how do I get a list of all (contiguous) sublists/substrings? The order is not important. Example for lists: ...
Martin Ender's user avatar
  • 8,774
5 votes
7 answers

Creating sums of elements from a list

I have a list $(d_1, d_2, .. d_k)$ and I want to create all sums that I get for adding only two elements for my list $(d_1+d_2, d_1+d_3,...d_{k-1}+d_k)$. The ...
WayneGacy's user avatar
  • 101
8 votes
3 answers

Replace For-loop with functional code

I am very new to Mathematica. I have code written using for loops. I want to rewrite it using Map/Thread but I am not sure how ...
Vajira's user avatar
  • 83
7 votes
1 answer

How to get all possible orderings (equal ranks allowed) for given set of $N$ objects?

Hope there is a solution besides the tedious generation of nested loops. (Trying to avoid reinventing the wheel.) Here is an example with $N = 3$ objects. There are $13$ needed orderings (first ...
aeiklmkv's user avatar
  • 177
5 votes
3 answers

How to use FoldList / NestList and Pure function for this?

Chen Stats Yu's user avatar
4 votes
3 answers

How to get multiplication of the elements of a specific list/Matrix

Assume there is a list: List1={a,b,c,d}; Then I want to get these calculation: ...
Shellp's user avatar
  • 523
3 votes
2 answers

Generating a sequence of lists [closed]

I have learnt how to generate a sequence of numbers, but now I come across a question whether it is possible to generate e sequence of lists. Say, I would like to generate {1},{1,2},{1,2,3},...,{1,2,3,...
Chen M Ling's user avatar