Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make tacit scalar replacement invertible #36

Open
tangentstorm opened this issue Sep 14, 2021 · 0 comments
Open

make tacit scalar replacement invertible #36

tangentstorm opened this issue Sep 14, 2021 · 0 comments

Comments

@tangentstorm
Copy link

tangentstorm commented Sep 14, 2021

I request that the idiomatic verb =&m`(,:&n) } for scalar m and n, be invertible. The inverse is =&n`(,:&m) } .

For example:

   in  =. =&'-'`(,:&'_') }
   out =. =&'_'`(,:&'-') }

   io  =. [: ". in :. out

   +:&.io '-1 2 3'
-2 4 6

could be rewritten more succinctly as:

    io =.  [: ". '-'&=`(,:&'_') }
    +:&.io '-1 2 3'
-2 4 6

This one new inverse would suffice for the majority of my use cases, but you may also consider making inverses for the verb's affiliates.

That is, you could create the following mappings (or a subset thereof):

   = &m`(,:&n) } ^:_1  ↔  = &n`(,:&m) }   NB. A
   ~:&m`(n&,:) } ^:_1  ↔  ~:&n`(m&,:) }   NB. B
   m& =`(,:&n) } ^:_1  ↔  n& =`(,:&m) }   NB. C
   m&~:`(n&,:) } ^:_1  ↔  n&~:`(m&,:) }   NB. D

   = &m`(n&,:) } ^:_1  ↔  = &n`(m&,:) }   NB. E
   ~:&m`(,:&n) } ^:_1  ↔  ~:&m`(,:&m) }   NB. F
   m& =`(n&,:) } ^:_1  ↔  n& =`(m&,:) }   NB. G
   m&~:`(,:&n) } ^:_1  ↔  n&~:`(,:&m) }   NB. H

But I'm not convinced these extra inverses provide much value:

  • Mappings E-H are going to see less use (it can be useful to say "replace everything that's not a FOO with a BAR, but it's not so useful to invert that function).
  • The form m&= is redundant with =&m. It's not so hard to write the latter if you want your function invertible.
  • A similar sentiment applies to ~:&m`(n&,:) vs =&m`(,:&n) .

-- Dan Bron <2008-02-01T23:45:30Z>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant