Key Topics | Skills to Master | Maple Commands | Examples of Use |
---|---|---|---|

Conditional Statements | Understand and write Maple expressions which evaluate to true or false. | (see ?boolean help page) | i = 1; |

j <= 2; | |||

(0 < x) and (x <= 1); | |||

x := Pi; type(x, realcons); | |||

Understand and write "if" statements, including those with "elif" and "else" clauses. | if | y := -1; if y = 0 then print("zero") elif y > 0 then print("positive") else print("negative") end if; | |

Loops | Write simple "for" loops with a fixed number of iterations. | for | for i from 1 to
10 do printf("%d^2 = %d\n", i, i^2); end do; |

Write nested "for" loops, including those with a variable number of iterations. | for | for i from 1 to
5 do for j from i+1 to 5 do print(i < j); end do; end do; | |

Lists | Create a list data structure in Maple and extract a single element from the list. | (see ?list help page) | L := [a,b,c]; L[2]; # second element |

Determine the number of elements in a list. | nops | nops(L); | |

Extract all the elements of a list. | op | op(L); | |

Append a new element to the end of a list. | (see ?list help page) | L := [op(L), d]; # append d | |

Generate the elements of a list automatically using a formula. | seq | squares := [seq(i^2, i=1..10)]; | |

Random Numbers | Create a random number generator in Maple. | rand | coin := rand(0..1); |

Generate a list of random numbers using a sequence. | seq | tosses := [seq(coin(), i=1..100)]; | |

Generate a list of random numbers using a loop. | for | tosses := []; for i from 1 to 100 do tosses := [op(tosses), coin()]; end do: # suppress loop output tosses; |

Created on 11/8/2006 by Jeremy Johnson
() and Frederick W. Chapman
().