Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor change to insert, switch, replace, RingMap acting on lists #3501

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion M2/Macaulay2/editors/emacs
Submodule emacs updated 1 files
+6 −6 M2.el
6 changes: 3 additions & 3 deletions M2/Macaulay2/m2/lists.m2
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions M2/Macaulay2/m2/ringmap.m2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions M2/Macaulay2/packages/Macaulay2Doc/doc3.m2
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
6 changes: 3 additions & 3 deletions M2/Macaulay2/packages/Macaulay2Doc/functions/insert-doc.m2
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
doc///
Key
insert
(insert,ZZ,Thing,VisibleList)
(insert,ZZ,Thing,BasicList)
Headline
copy a list, inserting an element
Usage
insert(i, x, L)
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
Expand Down
6 changes: 3 additions & 3 deletions M2/Macaulay2/packages/Macaulay2Doc/functions/replace-doc.m2
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ doc ///

doc ///
Key
(replace, ZZ, Thing, VisibleList)
(replace, ZZ, Thing, BasicList)
Headline
copy a list, replacing an element
Usage
s = replace(i, t, l)
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
Expand Down
6 changes: 3 additions & 3 deletions M2/Macaulay2/packages/Macaulay2Doc/functions/switch-doc.m2
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
doc///
Key
switch
(switch,ZZ,ZZ,VisibleList)
(switch,ZZ,ZZ,BasicList)
Headline
copy a list, switching two elements
Usage
switch(i, j, L)
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
Expand Down
Loading