Skip to content

Berkeley2014_"5_things_I_wish_I_knew"

Mahrud Sayrafi edited this page Mar 12, 2021 · 1 revision

title: Berkeley2014 "5 things I wish I knew" permalink: wiki/Berkeley2014_"5_things_I_wish_I_knew"/ layout: wiki

As the workshop progresses, please make a short list of things that you learned about Macaulay2 while at the workshop. These pages often contain quite a few gems at the end of the week!

Return to the Main Berkeley2014 page

Courtney Gibbons

  • The command apply has already changed my life; now I know applyTable (see the applyTable Documentation). This is useful for applying a function to nested lists.
  • Dealing with lists and functions, part 2: Let's say you have a list L of lists or sequences and you want to apply a function (like first, which grabs the first element in a list or sequence) to each list in L. You can do this using a single backslash:

   i1: {(1,2,3),(4,5,6),(7,8,9)} / first
   o1: {1,4,7}
   o1: List

If instead you want the first element of L itself, you can use two backslashes:

   i2: {(1,2,3),(4,5,6),(7,8,9)} // first
   o2: (1,2,3)
   o2: Sequence

  • This might be silly, but if you are using a Mac, you can still use f11 and f12 for Macaulay2 in emacs by requiring "fn" to use the f key functions (e.g., f11 lowers the volume). Go to System Preferences -> Keyboard -> Keyboard and check the box for "Use all F1, F2, etc. keys as standard function keys."

Branden Stone

  • Packages have an AuxiliaryFiles option that allows the user to include a directory with the package. See the newPackage documentation for more info.
  • In order to get input from the user use the 'read' command. For example

      ans = read "Would you like to continue? (y or n)"
      if ans == "y" then print "keep doing your thing" else print "stop"

Robert Krone

  • Manipulating data stored as matrices runs much faster than as nested lists (especially if it's sparse). For example instead of sorting a list of lists of integers, you can sort the columns of matrix.

Jason Lutz

  • I've found the command code to be very helpful for debugging. For example, the command ?map indicates that one way to use map is map(Module, Module, Matrix); in this case the command code(map, Module, Module, Matrix) displays the Macaulay2 code for this method. Similarly, the command code(symbol **, Ring, Ring) shows the code associated with the command Ring ** Ring.
  • When building/testing methods, f11 is can be inefficient. Instead, utilize the command load, placing all examples after end and using f11 starting with the line containing restart:

 --file with new methods to test is newMethods.m2
 method1 = method()
 method1 InputType1 := OutputType1 -> I -> (
 --desired commands for this method
 )
 
 method2 = method ()
 --etc
 
 end
 restart
 load "newMethods.m2"
 -- begin examples for testing/debugging the new methods

Clone this wiki locally