 Simon
SimonGuest
		
		
	 
	
		
		Does q have the ability to return from a function early? Like “break” in C++ ?
		
	 
 
		
			
	
	
		
		kdb supports the full range of execution controls, while, if, do, exceptions.
Consider the following while loop:
q){ i:0; while[i<5; show "hello ",string i; i+:1] }[]
"hello 0"
"hello 1"
"hello 2"
"hello 3"
"hello 4"
If we wanted to break from it early dependent on a condition we could do:
q){ i:0; while[i<5; show "hello ",string i; if[i~3; :`p]; i+:1] }[]
"hello 0"
"hello 1"
"hello 2"
"hello 3"
`p
The single colon at :`p with nothing on the left is the equivalent of return in most other languages.
Some more details on debugging and exceptions can be found at:
http://www.timestored.com/kdb-guides/debugging-kdb