########## # File @(#) Bdr2Part (PART PACKAGE) Wed Feb 26 19:16:36 MET 1997 ########## interface(verboseproc=0); # # Border2Part(border) returns the partition (tableau) corresponding to the # given border. # The border is a list of 0 and 1, 0 denoting an # horizontal chunk, 1 a vertical one. # Extremity segments shall not be included (i.e. 1 on the # left top, 0 on the right bottom). # The returned partition is in decreasing order. # # renvoie la partition (le tableau) correspondant a la # frontiere en argument. # La frontiere est une liste de 0 et de 1, 0 correspondant # a un morceau horizontal, 1 a un morceau vertical. # Les portions extremes ne sont pas incluses (1 en haut # a gauche, 0 en bas a droite). # La partition renvoyee est en ordre decroissant. # # Border2Part(border, m) returns the same, m[1] denoting an horizontal chunk # of the border, m[2] a vertical one. # # Border2Part(border, m) renvoie la meme chose, m[1] correspondant a un # segment horizontal, m[2] un segment vertical. # # VP260297 SV280798 `PART/Border2Part/int` := proc(border) local i, # variable for loop... h, # horizontal encoding... n, # number of horizontal segments lambda; # the result lambda := NULL; n := 0; if (nargs = 2) then h := op(1,args[2]); else h := 0; fi; for i from 1 to nops(border) do if (border[i] = h) then n := n+1; else lambda := n, lambda; fi; od; [lambda] end; # # VP230397 # Interfacing options... `PART/Border2Part` := proc(border) local i, # variable for loop... alphbt; # the alphabet... alphbt := NULL; # default value... if (nargs >= 2) then for i from 2 to nargs do if (op(1, args[i]) = 'alphabet') then alphbt := op(2, args[i]); fi; od; fi; `PART/Border2Part/int`(border,alphbt); end; # # SV240497 `PART/Border2Part/interface` := proc(border) `PART/Border2Part`(args); end; # # This is the same function but for the PART package so that it provides # some verifications on the arguments. # # VP260297 `PART/Border2Part/check` := proc(border) if (nargs >= 2) then if (type(args[2],`=`)) then if (op(1, args[2]) = 'alphabet') then if (not type(op(2, args[2]), list)) then ERR['PARTPerror'](4,procname); elif (nops(op(2, args[2]))<>2) then ERR['PARTPerror'](4,procname); fi; else ERR['PARTPerror'](4,procname); fi; else ERR['PARTPerror'](3,procname); fi; if (not TYP['IsBorder'](args[1], args[2..nargs])) then ERR['PARTPerror'](1,procname); fi; elif (not TYP['IsBorder'](args[1])) then ERR['PARTPerror'](1,procname); fi; end; # # SV160497 `PART_PACK/Border2Part` := proc(border) `PART/Border2Part/check`(args); `PART/Border2Part/interface`(args); end; # savelib(`PART/Border2Part/int`, `PART/Border2Part/int.m`); savelib(`PART/Border2Part`, `PART/Border2Part.m`); savelib(`PART/Border2Part/interface`, `PART/Border2Part/interface.m`); savelib(`PART/Border2Part/check`, `PART/Border2Part/check.m`); savelib(`PART_PACK/Border2Part`, `PART_PACK/Border2Part.m`); if (not assigned(_NOQUIT)) then quit; fi;