From 63d636a41bee2e01ca0ad0d26f9343b46732240a Mon Sep 17 00:00:00 2001 From: pzinn Date: Sun, 29 Sep 2024 11:22:00 +1000 Subject: [PATCH 1/2] minor change to insert, switch, replace, RingMap acting on lists --- M2/Macaulay2/m2/lists.m2 | 6 +++--- M2/Macaulay2/m2/ringmap.m2 | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/M2/Macaulay2/m2/lists.m2 b/M2/Macaulay2/m2/lists.m2 index 65ee3a44d97..0e31c03f01e 100644 --- a/M2/Macaulay2/m2/lists.m2 +++ b/M2/Macaulay2/m2/lists.m2 @@ -267,20 +267,20 @@ commonest Tally := t -> ( -- suggested by Allen Knutson: insert = method() -insert(ZZ,Thing,VisibleList) := VisibleList => (i,x,s) -> ( +insert(ZZ,Thing,BasicList) := BasicList => (i,x,s) -> ( j := i; if j < 0 then j = j + #s + 1; if j < 0 or j > #s then error("insert: index ", toString i, " out of bounds: 0..", toString length s); join(take(s,{0,j-1}),{x},take(s,{j,#s-1}))) switch = method() -switch(ZZ,ZZ,VisibleList) := VisibleList => (i,j,s) -> ( +switch(ZZ,ZZ,BasicList) := BasicList => (i,j,s) -> ( t := new MutableList from s; t#i = s#j; t#j = s#i; new class s from t) -- -replace(ZZ,Thing,VisibleList) := VisibleList => {} >> o -> (i,x,s) -> ( +replace(ZZ,Thing,BasicList) := BasicList => {} >> o -> (i,x,s) -> ( j := i; if j < 0 then j = j + #s; if j < 0 or j >= #s then error("replace: index ", toString i, " out of bounds: 0..", toString (length s - 1)); diff --git a/M2/Macaulay2/m2/ringmap.m2 b/M2/Macaulay2/m2/ringmap.m2 index ef4f978de2e..c7326ff713e 100644 --- a/M2/Macaulay2/m2/ringmap.m2 +++ b/M2/Macaulay2/m2/ringmap.m2 @@ -223,8 +223,8 @@ tensor(RingMap, Matrix) := Matrix => {} >> opts -> (f, m) -> ( map(f ** target m, f ** source m, f cover m)) RingMap ** Matrix := Matrix => (f, m) -> tensor(f, m) -List / RingMap := List => (v,f) -> apply(v,x -> f x) -RingMap \ List := List => (f,v) -> apply(v,x -> f x) +VisibleList / RingMap := VisibleList => (v,f) -> apply(v,x -> f x) +RingMap \ VisibleList := VisibleList => (f,v) -> apply(v,x -> f x) ----------------------------------------------------------------------------- -- kernel From 63c5250780072216752f14a95f0b5b2c8dd5e0b1 Mon Sep 17 00:00:00 2001 From: pzinn Date: Sun, 29 Sep 2024 11:42:31 +1000 Subject: [PATCH 2/2] doc update for insert, switch, replace, RingMap acting on lists --- M2/Macaulay2/packages/Macaulay2Doc/doc3.m2 | 4 ++-- M2/Macaulay2/packages/Macaulay2Doc/functions/insert-doc.m2 | 6 +++--- M2/Macaulay2/packages/Macaulay2Doc/functions/replace-doc.m2 | 6 +++--- M2/Macaulay2/packages/Macaulay2Doc/functions/switch-doc.m2 | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/M2/Macaulay2/packages/Macaulay2Doc/doc3.m2 b/M2/Macaulay2/packages/Macaulay2Doc/doc3.m2 index 064152ab516..818a8ffd049 100644 --- a/M2/Macaulay2/packages/Macaulay2Doc/doc3.m2 +++ b/M2/Macaulay2/packages/Macaulay2Doc/doc3.m2 @@ -124,13 +124,13 @@ document { (symbol \,Function,VirtualTally), (symbol \,SelfInitializingType,VisibleList), (symbol \,Command,VisibleList), - (symbol \,RingMap,List), + (symbol \,RingMap,VisibleList), (symbol \,Command,VirtualTally), (symbol /,VisibleList,SelfInitializingType), (symbol /,List,Command), (symbol /,VirtualTally,Command), (symbol /,VirtualTally,Function), - (symbol /,List,RingMap), + (symbol /,VisibleList,RingMap), (symbol /,VisibleList,Command), (symbol /,String,Command), (symbol /,String,Function), diff --git a/M2/Macaulay2/packages/Macaulay2Doc/functions/insert-doc.m2 b/M2/Macaulay2/packages/Macaulay2Doc/functions/insert-doc.m2 index 40088dd2f33..30940a933e7 100644 --- a/M2/Macaulay2/packages/Macaulay2Doc/functions/insert-doc.m2 +++ b/M2/Macaulay2/packages/Macaulay2Doc/functions/insert-doc.m2 @@ -4,7 +4,7 @@ doc/// Key insert - (insert,ZZ,Thing,VisibleList) + (insert,ZZ,Thing,BasicList) Headline copy a list, inserting an element Usage @@ -12,9 +12,9 @@ doc/// Inputs i: ZZ x: Thing - L: VisibleList + L: BasicList Outputs - L2: VisibleList + L2: BasicList a copy of {\tt L} in which {\tt x} has been inserted into position {\tt i} Description Example diff --git a/M2/Macaulay2/packages/Macaulay2Doc/functions/replace-doc.m2 b/M2/Macaulay2/packages/Macaulay2Doc/functions/replace-doc.m2 index 159a90443e8..002a08a4672 100644 --- a/M2/Macaulay2/packages/Macaulay2Doc/functions/replace-doc.m2 +++ b/M2/Macaulay2/packages/Macaulay2Doc/functions/replace-doc.m2 @@ -68,7 +68,7 @@ doc /// doc /// Key - (replace, ZZ, Thing, VisibleList) + (replace, ZZ, Thing, BasicList) Headline copy a list, replacing an element Usage @@ -76,9 +76,9 @@ doc /// Inputs i:ZZ t:Thing - l:VisibleList + l:BasicList Outputs - s:VisibleList + s:BasicList a copy of the list @TT "l"@ in which @TT "t"@ has replaced the element at position @TT "i"@. Description Text diff --git a/M2/Macaulay2/packages/Macaulay2Doc/functions/switch-doc.m2 b/M2/Macaulay2/packages/Macaulay2Doc/functions/switch-doc.m2 index e70ac98b91f..021cadfc787 100644 --- a/M2/Macaulay2/packages/Macaulay2Doc/functions/switch-doc.m2 +++ b/M2/Macaulay2/packages/Macaulay2Doc/functions/switch-doc.m2 @@ -4,7 +4,7 @@ doc/// Key switch - (switch,ZZ,ZZ,VisibleList) + (switch,ZZ,ZZ,BasicList) Headline copy a list, switching two elements Usage @@ -12,9 +12,9 @@ doc/// Inputs i: ZZ j: ZZ - L: VisibleList + L: BasicList Outputs - L2: + L2: BasicList a copy of the list {\tt L}, with the elements in positions {\tt i} and {\tt j} interchanged. Description Text