- Aggregated Pivot Table
- Bit Shifting
- Bitwise XOR
- Calculate Tick Size
- Collapsing Dictionaries
- Graphs - Breadth First Search
- Graphs - Depth First Search
- Graphs - Detecting Cycles
- Greatest Common Divisor
- Identity Matrix
- Least Common Multiple
- Log Parser
- Nanosleep
- One Hot Encoding
- Parent Child ID Mapping
- Slippage
- Split Training and Testing Sets
- Stratified Sampling
- Symbol Column Update
- Table Indexing
- Word Count
Sleep
Question: Define a function 'sleep' that behaves similarly to the Unix system command 'sleep'. The function should receive a 'time' as the input argument.
More Information:
https://en.wikipedia.org/wiki/Sleep_(command)Example
q)\t sleep each 1e3*1 2 5 / seconds
7999
q)\t sleep 500 / millis
499
Solution
######## solution.q ########
sleep:{st:.z.T; while[.z.T<st+x;()]}
Explanation: Store the current time in a variable, and use a while loop that does not end until the current time is greater than or equal to the stored time plus the input time.