mirror of
				https://github.com/Dummi26/mers.git
				synced 2025-10-31 11:46:15 +01:00 
			
		
		
		
	update examples
This commit is contained in:
		
							parent
							
								
									db59a1e92e
								
							
						
					
					
						commit
						cab81059f3
					
				| @ -3,10 +3,10 @@ gcd := vals -> { | |||||||
|     (a, b) := vals |     (a, b) := vals | ||||||
|     if a.eq(b) |     if a.eq(b) | ||||||
|       (a) |       (a) | ||||||
|     else if a.diff(b).signum.eq(1) |     else if b.subtract(a).signum.eq(1) | ||||||
|       &vals = (a, a.diff(b)) |       &vals = (a, b.subtract(a)) | ||||||
|     else |     else | ||||||
|       &vals = (b.diff(a), b) |       &vals = (a.subtract(b), b) | ||||||
|   } |   } | ||||||
| }.loop | }.loop | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -62,7 +62,7 @@ read_matrix_line := width -> { | |||||||
|       if w.eq(0) { |       if w.eq(0) { | ||||||
|         width = line.len |         width = line.len | ||||||
|       } else { |       } else { | ||||||
|         {() -> if line.len.diff(w).signum.eq(1) { |         {() -> if line.len.subtract(w).signum.eq(-1) { | ||||||
|           &line.push(0.0) |           &line.push(0.0) | ||||||
|         } else (())}.loop |         } else (())}.loop | ||||||
|       } |       } | ||||||
| @ -86,10 +86,10 @@ matrix_get := (matrix, (line, col)) -> { | |||||||
| 
 | 
 | ||||||
| leftpad := (str, l) -> { | leftpad := (str, l) -> { | ||||||
|   str := (str).concat |   str := (str).concat | ||||||
|   d := str.len.diff(l) |   d := l.subtract(str.len) | ||||||
|   {() -> if d.signum.eq(1) { |   {() -> if d.signum.eq(1) { | ||||||
|     &str = (" ", str).concat |     &str = (" ", str).concat | ||||||
|     &d = 1.diff(d) |     &d = d.subtract(1) | ||||||
|   } else {(())}}.loop |   } else {(())}}.loop | ||||||
|   str |   str | ||||||
| } | } | ||||||
| @ -100,11 +100,11 @@ matrix_print := matrix -> { | |||||||
|   val_len := 0 |   val_len := 0 | ||||||
|   matrix.for_each(line -> { |   matrix.for_each(line -> { | ||||||
|     l := line.len |     l := line.len | ||||||
|     if l.diff(width).signum.eq(-1) |     if width.subtract(l).signum.eq(-1) | ||||||
|       &width = l |       &width = l | ||||||
|     line.for_each(val -> { |     line.for_each(val -> { | ||||||
|       l := (val).concat.len |       l := (val).concat.len | ||||||
|       if l.diff(val_len).eq(-1) |       if val_len.subtract(l).eq(-1) | ||||||
|         &val_len = l |         &val_len = l | ||||||
|     }) |     }) | ||||||
|   }) |   }) | ||||||
|  | |||||||
| @ -68,7 +68,7 @@ range := (min, max, inc) -> { | |||||||
|   val := min |   val := min | ||||||
|   () -> { |   () -> { | ||||||
|     // -1 if val > max, 1 if max > val, 0 if max = val |     // -1 if val > max, 1 if max > val, 0 if max = val | ||||||
|     should_inc := ((val, max).diff.signum, inc.signum).eq |     should_inc := ((max, val).subtract.signum, inc.signum).eq | ||||||
|     if should_inc { |     if should_inc { | ||||||
|       v := val |       v := val | ||||||
|       &val = (val, inc).sum |       &val = (val, inc).sum | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Mark
						Mark