It would not be correct.  It signals domain error on a non-invertible function.



On Wed, Nov 2, 2011 at 11:37 AM, Andrew Pennebaker
<[email protected]> wrote:
> Would it be correct to say ^:_1 uses memoization?
>
> If so, when does the memoization happen? Does J memoize the function to be
> ^:_1'd as soon as the function is defined, or does J wait to do so when
> ^:_1 is called?
>
> What does J do if you try to ^:_1 a non-injective function? Does it just
> return the first correct input it encounters?
>
> Cheers,
>
> Andrew Pennebaker
> www.yellosoft.us
>
> On Wed, Nov 2, 2011 at 2:23 PM, Roger Hui <[email protected]> wrote:
>
>> > How powerful is J's ^:_1 operator?
>> Very.
>>
>> > How is it implemented?
>> Carefully. ☺  It's a giant table look-up.  Some of the inverses were
>> put in to impress particular people, lying in wait for years.  (It
>> worked!  Worth all the effort and all the waiting because of who it
>> was.)
>>
>> See http://www.jsoftware.com/jwiki/Essays/Under , the raison d'être
>> for having inverses.
>>
>>
>>
>> On Wed, Nov 2, 2011 at 11:14 AM, Andrew Pennebaker
>> <[email protected]> wrote:
>> > Fascinating.
>> >
>> > How powerful is J's ^:_1 operator? How is it implemented?
>> >
>> > Cheers,
>> >
>> > Andrew Pennebaker
>> > www.yellosoft.us
>> >
>> > On Wed, Nov 2, 2011 at 10:02 AM, Roger Hui <[email protected]
>> >wrote:
>> >
>> >> It's better to define functions in the form "F from G" rather than "G
>> >> to F", because then the argument and result would be adjacent to the
>> >> function whose domain/range they are in:
>> >>
>> >> f =: FfG g
>> >> f =: GtF g
>> >>
>> >>
>> >>
>> >> On Wed, Nov 2, 2011 at 1:32 AM, Alan Stebbens <[email protected]> wrote:
>> >> >> How would one parse a hex string back to an integer?
>> >> >
>> >> > Two ways:
>> >> >
>> >> > Hard way:
>> >> >
>> >> >   H2D =: [: +/ 16 1 * '0123456789abcdef' I. ]
>> >> >   H2D 'A0'
>> >> > 160
>> >> >
>> >> > Easy way:
>> >> >
>> >> >   h2d =: d2h ^:_1
>> >> >   h2d 'a0'
>> >> > 160
>> >> >  h2d d2h i.20
>> >> > 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
>> >> >
>> >> >
>> >> > ----------------------------------------------------------------------
>> >> > For information about J forums see
>> http://www.jsoftware.com/forums.htm
>> >> >
>> >> ----------------------------------------------------------------------
>> >> For information about J forums see http://www.jsoftware.com/forums.htm
>> >>
>> > ----------------------------------------------------------------------
>> > For information about J forums see http://www.jsoftware.com/forums.htm
>> >
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to