-
Notifications
You must be signed in to change notification settings - Fork 0
Berkeley2014_"5_things_I_wish_I_knew"
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
- 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
- macaulay2.com brings you to the Macaulay2 homepage
- 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."
- 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"
- There exists commands that allow you to manipulate files as well as test for existence. See the file manipulation documentation for more info.
- 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.
- 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
-
Home
- Introduction
- Macaulay2 Contribution Guides
- Macaulay2 Workshop Guides
-
Macaulay2 Internals
- Building Macaulay2 from source
- Components of Macaulay2
- Case Studies
- Web servers
- Other
- Frequently Asked Questions
- Road map