Sorry for wrong language, I saw a challenge and took it. Here is the code converted back to factor, and much easier to read than the original IMO. (Concatenative programming is hard to read). :: (basis) ( dim n -- v ) [ 1 ] n dim [ 0 ] replicate [ set-nth ] keep ; :: (bases) ( dim -- {v} ) dim iota [ dim basis ] map ; :: (grad) ( quot: ( loc -- field ) step loc -- v ) loc length (bases) [ step v*n ] map [ loc v+ ] map quot loc quot - step / ; :: grad ( quot: ( loc -- field ) loc -- v ) quot 0.01 loc (grad) ;