forked from HEL/chronos
		
	added groups
This commit is contained in:
		
							
								
								
									
										27
									
								
								src/utils.typ
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/utils.typ
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| #let get-participants-i(participants) = { | ||||
|   let pars-i = (:) | ||||
|   for (i, p) in participants.enumerate() { | ||||
|     pars-i.insert(p.name, i) | ||||
|   } | ||||
|   return pars-i | ||||
| } | ||||
|  | ||||
| #let get-group-span(participants, group) = { | ||||
|   let min-i = participants.len() - 1 | ||||
|   let max-i = 0 | ||||
|   let pars-i = get-participants-i(participants) | ||||
|  | ||||
|   for elmt in group.elmts { | ||||
|     if elmt.type == "seq" { | ||||
|       let i1 = pars-i.at(elmt.p1) | ||||
|       let i2 = pars-i.at(elmt.p2) | ||||
|       min-i = calc.min(min-i, i1, i2) | ||||
|       max-i = calc.max(max-i, i1, i2) | ||||
|     } else if elmt.type == "grp" { | ||||
|       let (i0, i1) = get-group-span(participants, elmt) | ||||
|       min-i = calc.min(min-i, i0) | ||||
|       max-i = calc.max(max-i, i1) | ||||
|     } | ||||
|   } | ||||
|   return (min-i, max-i) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user