Skip to content

5_things_I_wish_I_knew_WF2012

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

title: 5 things I wish I knew WF2012 permalink: wiki/5_things_I_wish_I_knew_WF2012/ layout: wiki

Alexandra Seceleanu

  • listLocalSymbols - display of local symbols and their values is very helpful for debugging
  • PackageImports and PackageExports will replace needsPackage in version 1.5
  • never type use R inside a package (it will potentially rewrite the user's variables)

Adam Boocher

  1. To help with debugging, if you want to print something to the screen while running, you can do
    • << L << endl;
    • (The << prints to the screen, and endl is a line break)
  2. for i from 1 to 5 list ( if i ==1 then continue else i)
    • This code is just like apply, although it has the option to use "continue" to not add an element to the list.
  3. The function drop(L,n) which drops the first (or last) n elements from a list depending on whether n is positive (or negative)

Maxim Arap

  • One may store additional data in a ring. For example, if S=QQ[x,y,z], one may store additional information about this ring as follows: S#info="useful info" and then access it later by S#info.
  • Running M2 with option -q may get rid of unexpected warnings.

Jason Lutz

When creating and subsequently overloading a method, avoiding the use of TypicalValue will prevent provlems in documentation. Instead, note the value of the output of the method(s) as follows:

 newMethod = method()
 newMethod InputType1 := OutputType1 -> I -> (
 --desired commands for this method
 )
 
 --overloading newMethod
 newMethod InputType2:= OutputType2 -> J -> (
 --desired commands for this method
 )

Then, documentation is entered as follows:

 doc ///
   Key
     (newMethod, InputType1)
   Headline
     newMethod taking InputType1 to OutputType1.
   Usage
     O = newMethod I
   Inputs
     I: --will automatically add the type InputType1
   Outputs
     O: --will automatically add the type OuputType1
 ///
 doc ///
   Key
     (newMethod, InputType2)
   Headline
     newMethod taking InputType2 to OutputType2.
   -- etc.
 ///

Return to the main WF2012 page

Thanh Vu

I can use Hom as the name for my functions. I can implement the method _ to my data type. MutableHashTable, and sorts of nice functions like netList, all. I can use svn and keystrokes with emacs.

Clone this wiki locally