Last active
August 29, 2015 13:58
-
-
Save yurivish/9947301 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xs =: (i: 10) % 10 | |
ys =: (i: 20) % 10 | |
grid =: ys j./ xs | |
in =: 4 > | | |
out =: 1 - in | |
trim =: (* in) + (_ * out) | |
iter =: trim @ (+ *:) | |
require 'viewmat' | |
viewmat grid iter^:1000 grid |
r =: {. + ([: i. len) NB. For (x y) passed in, return the range x + i. len x
(this leaves out the endpoint)
len =: -@- NB. Monadic minus composed with dyadic minus. Usage: x len y
Alternate formulation: [: - - or [: | -
And now you can define
r =: [ + ([: i. len)
which is equal x + the range from 0 to (x len y)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
len =: -/ |. NB. Subtract the right index from the left index by reversing the list and inserting a minus.
Better:
len =: }. - {. NB. Subtract the second from the first