! Generate 1000 random vectors ! Compute pairwise distances ! Output the smallest one USING: math math.combinatorics math.order math.vectors math.functions random sequences tools.time ; IN: speed1 CONSTANT: test-size 1000 : u01 ( -- u ) 0. 1. uniform-random-float ; : rv ( -- v ) 3 [ u01 ] replicate ; : rvs ( n -- vv ) [ rv ] replicate ; : dist ( v w -- n ) v- norm-sq sqrt ; : main-test ( -- result seconds ) [ test-size rvs 2 1. [ first2 dist min ] reduce-combinations ] benchmark 1e9 / ; MAIN: main-test