Results 1 to 6 of 6

Math Help - Mathematica: Lists

  1. #1
    Junior Member
    Joined
    Oct 2008
    Posts
    49

    Mathematica: Lists

    Hi all

    I have the following code:

    For[i = 0, i < 98, i++,
    q = i*100;
    For[j = 102 + q, j < 2*100 + q, j++,
    Print[j]]]

    The output of this loop I wish to put in a list. Can you guys give me a hint to do that?

    Sincerely,
    Niles.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Junior Member
    Joined
    Oct 2008
    Posts
    49
    Ok, I just used Create Lists - Wolfram Mathematica 7 Documentation

    Mathematica is well-documented.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Feb 2010
    From
    Lisbon
    Posts
    51
    You can always define a help variable

    res=\{ \}

    and replace Print[j] with AppendTo[res,j]. At the end, just ask the program to return res.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Junior Member
    Joined
    Oct 2008
    Posts
    49
    That solution was much nicer than mine; thanks. Do you know if it is possible to perform multiple tasks in an if-condition? I.e.

    If[2>1,
    Do this
    Also do this
    Also do this and this,
    Else only do this
    ]

    ?
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Junior Member
    Joined
    Feb 2010
    From
    Lisbon
    Posts
    51
    Of course:

    If [ Condition, Action 1; Action 2; Actions 3; ... ; Action n].

    Just separate the tasks by ; and keep the , for telling the If what to do should the condition fail to be true.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Junior Member
    Joined
    Oct 2008
    Posts
    49
    Thanks, I appreciate it.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Graphing Instructions Problem - Lists
    Posted in the Calculators Forum
    Replies: 0
    Last Post: July 30th 2011, 08:35 PM
  2. Replies: 0
    Last Post: June 3rd 2011, 10:40 AM
  3. 3-lists taken from [3]
    Posted in the Discrete Math Forum
    Replies: 5
    Last Post: May 18th 2010, 08:20 AM
  4. Prove DeMorgan's Law and Counting Using Lists
    Posted in the Discrete Math Forum
    Replies: 0
    Last Post: September 15th 2009, 03:32 PM
  5. Creating and plotting multiple lists
    Posted in the Math Software Forum
    Replies: 1
    Last Post: October 9th 2008, 03:34 PM

Search Tags


/mathhelpforum @mathhelpforum