about summary refs log tree commit diff stats
path: root/awk/rawk/scratch/debug_findindex.rawk
diff options
context:
space:
mode:
Diffstat (limited to 'awk/rawk/scratch/debug_findindex.rawk')
-rw-r--r--awk/rawk/scratch/debug_findindex.rawk38
1 files changed, 38 insertions, 0 deletions
diff --git a/awk/rawk/scratch/debug_findindex.rawk b/awk/rawk/scratch/debug_findindex.rawk
new file mode 100644
index 0000000..eabd13a
--- /dev/null
+++ b/awk/rawk/scratch/debug_findindex.rawk
@@ -0,0 +1,38 @@
+BEGIN {
+    print "=== Debug findIndex Test ==="
+}
+
+RAWK {
+    $is_positive_num = (x) -> {
+        return x > 0;
+    };
+}
+
+{
+    # Create test data
+    mixed[1] = -2;
+    mixed[2] = 0;
+    mixed[3] = 3;
+    mixed[4] = -5;
+    mixed[5] = 10;
+    
+    print "Test data:";
+    for (i = 1; i <= 5; i++) {
+        print "  mixed[" i "] = " mixed[i] " (positive: " is_positive_num(mixed[i]) ")";
+    }
+    
+    # Test findIndex
+    first_positive_index = findIndex("is_positive_num", mixed);
+    print "findIndex result:", first_positive_index;
+    
+    # Manual check
+    for (i = 1; i <= 5; i++) {
+        if (is_positive_num(mixed[i])) {
+            print "Manual check: first positive at index", i;
+            break;
+        }
+    }
+    
+    print "Test completed";
+    exit 0;
+} 
\ No newline at end of file
32 33 34 35 36 37 38 39 40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63