Hmm... I think I'd do it something like this:
parse=: 0,".@rplc&('^>v<';"0 <;.1' 1j0 0j1 _1j0 0j_1')
(I was initially inclined to leave out the unnecessary 'j0' bits, but
I think putting them in makes this slightly easier to read.)
Then the part 1 would examples be:
#~.+/\parse '>'
2
#~.+/\parse '^>v<'
4
#~.+/\parse '^v^v^v^v^v'
2
Depending on part 2, I might later remove the '0,' from parse and make
it be a part of my part1 implementation.
Note that other approaches (like using 1 0, 0 _1, _1 0,:0 1 or
whatever) could easily be made to work, but for simple 2d coordinates,
I prefer using complex numbers. Still, if you wanted to do it that
way, you could go like this:
parse=: 0,".@rplc&('^>v<';"0 <;._1'/1 0/0 1/_1 0/0 _1')"0
I hope this helps,
--
Raul
> To unsubscribe from this group and stop receiving emails from it, send an email to
forum+un...@jsoftware.com.