First negative number
FreeLogic@rabbinatix/first-negative-number by Rabbinatixupdated Oct 4, 2026
Finds the first number below zero and stops looking.
Break leaves the For Each early: the loop fires Completed straight away. Without a match the result is null at index −1.
Shows: For Each with element and index, Less Than, Break, Variables with defaults.
How to use it
Add it to your logic, then add a Call Function step in any logic and pick First negative. It belongs to no system, so every system can use it. Or download the TypeScript and call it from your own code.
Inputs
numbers: List of numbers
Outputs
value: Number (may be empty)
index: Whole number
Previewdrag the steps around; scroll to zoom
Function Entry, Input / output. 0 inputs, 2 outputs. step 1 of 10
First negative
numbers
For Each, Flow control. 2 inputs, 4 outputs. step 2 of 10
For Each
array
Loop Body
element
index
Completed
Less Than, Operators. 2 inputs, 1 output. step 3 of 10
<
A
B
result
Branch, Flow control. 2 inputs, 2 outputs. step 4 of 10
Branch
condition
True
False
Set Variable, Data. 2 inputs, 2 outputs. step 5 of 10
Set found
value
value
Set Variable, Data. 2 inputs, 2 outputs. step 6 of 10
Set at
value
value
Break, Flow control. 1 input, 0 outputs. step 7 of 10
Break
Get Variable, Data. 0 inputs, 1 output. step 8 of 10
Get found
value
Get Variable, Data. 0 inputs, 1 output. step 9 of 10
Get at
value
Return, Input / output. 3 inputs, 0 outputs. step 10 of 10
Return
value
index
Arrow keys: next or previous step in flow order. Alt with arrows: nearest step in that direction. Enter: open. Shift F10: more actions.
Examplesrun live against the logic · 2/2 pass
| Passed | Example | Input | Output |
|---|---|---|---|
| Found | {"numbers":[3,-2,-7]} | {"value":-2,"index":1} | |
| None | {"numbers":[1,2]} | {"value":null,"index":-1} |
Try it
Versions
In this package
First negative (entry)
