# Search for a Hadamard difference set # Read("ShiftProcedures_2007.txt"); # Ken Smith # June 23, 2007 ############################################################ # Shift Procedures ############################################################ ShiftLeft := function( list, shift ) local length, list2, i, x; length := Size(list); list2 := ShallowCopy(list); for i in [1..length] do x := (shift+i-1) mod length; list2[i] := list[x+1]; od; return list2; end; ShiftLeft_2D := function( list, shift ) local length, list2, x; # We shift b2, which requires shifting all the entries in b2. list2 := [ ]; for x in list do Add( list2, ShiftLeft(x, shift ) ); od; return list2; end; ShiftLeft_3D := function( list, shift ) local length, list2, x; # We shift b2, which requires shifting all the entries in b2. list2 := [ ]; for x in list do Add( list2, ShiftLeft_2D(x, shift ) ); od; return list2; end; # I tried to create a faster subroutine, but this is # about the same timing as ShiftLeft_3D... ShiftLeft_3D_new := function( list, shift ) local length, list2, list3, x; # We shift b2, which requires shifting all the entries in b2. list2 := [ ]; for x in list do # x is a list of lists list3 := [ ]; for y in x do # y is a list Add( list3, ShiftLeft(y, shift ) ); od; Add( list2, list3 ); od; return list2; end; DemoFlag := 0; # Don't demo. Change this to 1 if you want to see the demos. if DemoFlag = 1 then # Demo list := [1,2,3,4,5,6,7,8,9,10,11]; Print("\nWe demo ShiftLeft: \n"); Print("Here is a list \n", list,"\nand here is ShiftLeft( list, 2 ):\n", ShiftLeft(list,2),"\n"); Sleep(3); # Demo listlist := [[1,2,3,4,5,6,7,8,9,10,11],[1,2,3,2,1,2,1,2,1,2,1],[1,2,3,4,5,6,7,8,9,10,11]]; Print("\nWe demo ShiftLeft_2D: \n"); Print("Here is a list of lists \n", listlist,"\nand here is ShiftLeft_2D( listlist, 2 ):\n", ShiftLeft_2D(listlist,2),"\n"); Sleep(3); # Demo listlistlist := [ [[1,2,3,4,5,6,7,8,9,10,11],[1,2,3,2,1,2,1,2,1,2,1],[1,2,3,4,5,6,7,8,9,10,11]], [[1,2,3,4,5,6,7,8,9,10,11],[9,8,7,6,5,4,3,2,1,0,-1],[1,2,3,4,5,6,7,8,9,10,11]], [[1,2,3,4,5,6,7,8,9,10,11],[1,2,3,2,1,2,1,2,1,2,1],[1,2,3,4,5,6,7,8,9,10,11]] ]; Print("\nWe demo ShiftLeft_3D: \n"); Print("Here is a list of lists of lists \n", listlistlist,"\nand here is ShiftLeft_3D( listlistlist, 2 ):\n", ShiftLeft_3D(listlistlist,2),"\n"); Sleep(3); fi;