From 06fb5aceeb65a75b1cd643debd667c52fdcafcb9 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Sun, 8 Nov 2026 14:10:02 -0800 Subject: Better error messages Better error messages. Buffs to the std lib; getch() to fetch a single character; streaming I/O handles retries, and large sizes, with better error reporting. Formatted strings. Default int moved to i32. TicTacToe, the game. --- chapter30/src/test/smp/examples/Dijkstra.smp | 72 ---------------------------- 1 file changed, 72 deletions(-) delete mode 100644 chapter30/src/test/smp/examples/Dijkstra.smp (limited to 'chapter30/src/test/smp/examples/Dijkstra.smp') diff --git a/chapter30/src/test/smp/examples/Dijkstra.smp b/chapter30/src/test/smp/examples/Dijkstra.smp deleted file mode 100644 index fd595eb5..00000000 --- a/chapter30/src/test/smp/examples/Dijkstra.smp +++ /dev/null @@ -1,72 +0,0 @@ - -// An implementation of -// https://sampleprograms.io/projects/dijkstra/ - -val shortestPath = { !sys.aryi64 matrix, int nodes, int src, int dst -> - i64 infinity = (1 << 63)-1; - var dist = new i64[nodes]; - var visited = new sys.adt.bitset(); - // All nodes are infinitely far from each other - for( int i=0; i 0 && !visited.get(node) && best+weight < dist[node] ) - dist[node] = best+weight; - } - } - count++; - } - return result; -}; - -val usage = { -> - sys.io.p("Usage: please provide three inputs: a serialized matrix, a source node and a destination node\n"); - return 0; -}; - -val main = { u8[~][] args -> - // Exactly 3 args - if( args# != 4 ) return usage(); - // First is a serialized square matrix of positive numbers - var matrix = sys.aryi64.parseAryI64(args[1]); - if( !matrix ) return usage(); - if( !matrix.len ) return usage(); - // All numbers are positive - for( int i=0; i= nodes || dst < 0 || dst >= nodes ) - return usage(); // Source and destination land within the graph - - i64 cost = shortestPath(matrix,nodes,src,dst); - if( cost >= 0 ) { - new sys.aryu8().num(cost).add('\n').write(1); - return 0; - } - return usage(); -}; -- cgit v1.2.3