wolfram-mathematicawolfram-language

Wolfram: How to create a list of pie charts for the sequence of digits in 10, 20 , 30


I want to be able to create multiple piecharts in a list. Each pie chart is an representation of the sequence of each argument.

Example: arguments -> 10, 20

arguments gets compiled into a sequence of numbers:

10 -> {1,2,3,4,5,6,7,8,9,10} and 20 -> {1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,17,18,19,20}

Now i need to create a list of piecharts that was formulated by those sequences.

i tried something and it worked but what if there were to be more arguments. How long would my solving code have to be to solve it:

List[PieChart[Range[10]], PieChart[Range[20]]]

enter image description here

Please help me or give me references on how to do this in a smarted way preparing for more arguments.


Solution

  • You should take a look at Map - Wolfram

    So lets imagine you have more arguments: {10,20,48,4.2}

    What you want to do is Map each function you want to use, on each one of them.

    So the functions you used was List, PieChart & Range


    soooo....

    Map Range to each argument to turn each of them into a sequence of 1 to 'argument' :

    Map[Range, {10,20,48,4.2}]
    

    Then map all those lists created by 'Range' to the function PieChart

    Map[PieChart, Map[Range, {10,20,48,4.2}]]