Skip to main content
Bounty Ended with 100 reputation awarded by Adám
added 56 characters in body
Source Link
Mukundan314
  • 12.7k
  • 1
  • 16
  • 58

*monadic + is the conjugate, but can be treated as identity for non complex inputs

*monadic + is the conjugate, but can be treated as identity for non complex inputs

added 56 characters in body
Source Link
Mukundan314
  • 12.7k
  • 1
  • 16
  • 58
(+,8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢)⊃1
‎⁡
(+,8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢)    # ‎⁢The ambivalent function:
 +                              # ‎⁣  monadic: identity (*); dyadic: left + right
  ,                             # ‎⁤  concatenated with
   8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢     # ‎⁢⁡‎⁣  octal and hexadecimal versions:
       {(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}       # ‎⁢⁢    dyadic function to convert int to base-n string:
        (⎕D,⎕A)                 # ‎⁢⁣      digits concatenated to alphabet
               [       ]        # ‎⁢⁤      indexed by
                      ⍵         # ‎⁣⁡        right argument
                 ⊥⍣¯1           # ‎⁣⁢        in base  (returns digit vector, e.g. 42 in base-16 is [2, 10])
                ⍺               # ‎⁣⁣        left argument
                         ¨      # ‎⁣⁤    applied to:
   8                      ⊢     # ‎⁤⁡      8 and right argument,
     16                   ⊢     # ‎⁤⁢      16 and right argument,
‎⁤⁣
# ‎⁤⁤‎⁤⁢To Summarize:
# ‎⁢⁡⁡‎⁤⁣  monadic version returns: [arg, oct(arg), hex(arg)]
# ‎⁢⁡⁢  dyadic version returns: [left + right, oct(right), hex(right)]
#     since left argument is always 1 when snippet is repeated, we can simplify it to
#     [1 + right, oct(right), hex(right)]
‎⁢⁡⁣
⊃   # ‎⁢⁡⁤pick first (extracts the current count)
    # when snippet is repeated this would be in front of all the dyadic calls
    # but not in front of the final monadic call

 1  # ‎⁢⁢⁡The initial count
💎
(+,8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢)⊃1
‎⁡
(+,8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢)    # ‎⁢The ambivalent function:
 +                              # ‎⁣  monadic: identity (*); dyadic: left + right
  ,                             # ‎⁤  concatenated with
   8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢     # ‎⁢⁡‎⁣  octal and hexadecimal versions:
       {(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}       # ‎⁢⁢    dyadic function to convert int to base-n string:
        (⎕D,⎕A)                 # ‎⁢⁣      digits concatenated to alphabet
               [       ]        # ‎⁢⁤      indexed by
                      ⍵         # ‎⁣⁡        right argument
                 ⊥⍣¯1           # ‎⁣⁢        in base  (returns digit vector, e.g. 42 in base-16 is [2, 10])
                ⍺               # ‎⁣⁣        left argument
                         ¨      # ‎⁣⁤    applied to:
   8                      ⊢     # ‎⁤⁡      8 and right argument,
     16                   ⊢     # ‎⁤⁢      16 and right argument,
‎⁤⁣
# ‎⁤⁤‎⁤⁢To Summarize:
# ‎⁢⁡⁡‎⁤⁣  monadic version returns: [arg, oct(arg), hex(arg)]
# ‎⁢⁡⁢  dyadic version returns: [left + right, oct(right), hex(right)]
‎⁢⁡⁣
⊃   # ‎⁢⁡⁤pick first (extracts the current count)
    # when snippet is repeated this would be in front of all the dyadic calls
    # but not in front of the final monadic call

 1  # ‎⁢⁢⁡The initial count
💎
(+,8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢)⊃1
‎⁡
(+,8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢)    # ‎⁢The ambivalent function:
 +                              # ‎⁣  monadic: identity (*); dyadic: left + right
  ,                             # ‎⁤  concatenated with
   8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢     # ‎⁢⁡‎⁣  octal and hexadecimal versions:
       {(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}       # ‎⁢⁢    dyadic function to convert int to base-n string:
        (⎕D,⎕A)                 # ‎⁢⁣      digits concatenated to alphabet
               [       ]        # ‎⁢⁤      indexed by
                      ⍵         # ‎⁣⁡        right argument
                 ⊥⍣¯1           # ‎⁣⁢        in base  (returns digit vector, e.g. 42 in base-16 is [2, 10])
                ⍺               # ‎⁣⁣        left argument
                         ¨      # ‎⁣⁤    applied to:
   8                      ⊢     # ‎⁤⁡      8 and right argument,
     16                   ⊢     # ‎⁤⁢      16 and right argument,
‎⁤⁣
# ‎⁤⁤‎⁤⁢To Summarize:
# ‎⁢⁡⁡‎⁤⁣  monadic version returns: [arg, oct(arg), hex(arg)]
# ‎⁢⁡⁢  dyadic version returns: [left + right, oct(right), hex(right)]
#     since left argument is always 1 when snippet is repeated, we can simplify it to
#     [1 + right, oct(right), hex(right)]
‎⁢⁡⁣
⊃   # ‎⁢⁡⁤pick first (extracts the current count)
    # when snippet is repeated this would be in front of all the dyadic calls
    # but not in front of the final monadic call

 1  # ‎⁢⁢⁡The initial count
💎
added 56 characters in body
Source Link
Mukundan314
  • 12.7k
  • 1
  • 16
  • 58
(+,8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢)⊃1
‎⁡
(+,8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢)    # ‎⁢The ambivalent function:
 +                              # ‎⁣  monadic: identity (*); dyadic: left + right
  ,                             # ‎⁤  concatenated with
   8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢     # ‎⁢⁡‎⁣  octal and hexadecimal versions:
       {(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}       # ‎⁢⁢    dyadic function to convert int to base-n string:
        (⎕D,⎕A)                 # ‎⁢⁣      digits concatenated to alphabet
               [       ]        # ‎⁢⁤      indexed by
                      ⍵         # ‎⁣⁡        right argument
                 ⊥⍣¯1           # ‎⁣⁢        in base  (returns digit vector, e.g. 42 in base-16 is [2, 10])
                ⍺               # ‎⁣⁣        left argument
                         ¨      # ‎⁣⁤    applied to:
   8                      ⊢     # ‎⁤⁡      8 and right argument,
     16                   ⊢     # ‎⁤⁢      16 and right argument,
‎⁤⁣
# ‎⁤⁤‎⁤⁢To Summarize:
# ‎⁢⁡⁡‎⁤⁣  monadic version returns: [arg, oct(arg), hex(arg)]
# ‎⁢⁡⁢  dyadic version returns: [left + right, oct(right), hex(right)]
‎⁢⁡⁣
                            ⊃   # ‎⁢⁡⁤pick first element (i.e.extracts the count/decimalcurrent representationcount)
    # when snippet is repeated this would be in front of all the dyadic calls
    # but not in front of the final monadic call

 1  # ‎⁢⁢⁡The initial count
💎
(+,8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢)⊃1
‎⁡
(+,8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢)    # ‎⁢The ambivalent function:
 +                              # ‎⁣  monadic: identity (*); dyadic: left + right
  ,                             # ‎⁤  concatenated with
   8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢     # ‎⁢⁡‎⁣  octal and hexadecimal versions:
       {(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}       # ‎⁢⁢    dyadic function to convert int to base-n string:
        (⎕D,⎕A)                 # ‎⁢⁣      digits concatenated to alphabet
               [       ]        # ‎⁢⁤      indexed by
                      ⍵         # ‎⁣⁡        right argument
                 ⊥⍣¯1           # ‎⁣⁢        in base  (returns digit vector, e.g. 42 in base-16 is [2, 10])
                ⍺               # ‎⁣⁣        left argument
                         ¨      # ‎⁣⁤    applied to:
   8                      ⊢     # ‎⁤⁡      8 and right argument,
     16                   ⊢     # ‎⁤⁢      16 and right argument,
‎⁤⁣
# ‎⁤⁤‎⁤⁢To Summarize:
# ‎⁢⁡⁡‎⁤⁣  monadic version returns: [arg, oct(arg), hex(arg)]
# ‎⁢⁡⁢  dyadic version returns: [left + right, oct(right), hex(right)]
‎⁢⁡⁣
                            ⊃   # ‎⁢⁡⁤pick first element (i.e. the count/decimal representation)
                             1  # ‎⁢⁢⁡The initial count
💎
(+,8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢)⊃1
‎⁡
(+,8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢)    # ‎⁢The ambivalent function:
 +                              # ‎⁣  monadic: identity (*); dyadic: left + right
  ,                             # ‎⁤  concatenated with
   8 16{(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}¨⊢     # ‎⁢⁡‎⁣  octal and hexadecimal versions:
       {(⎕D,⎕A)[⍺⊥⍣¯1⊢⍵]}       # ‎⁢⁢    dyadic function to convert int to base-n string:
        (⎕D,⎕A)                 # ‎⁢⁣      digits concatenated to alphabet
               [       ]        # ‎⁢⁤      indexed by
                      ⍵         # ‎⁣⁡        right argument
                 ⊥⍣¯1           # ‎⁣⁢        in base  (returns digit vector, e.g. 42 in base-16 is [2, 10])
                ⍺               # ‎⁣⁣        left argument
                         ¨      # ‎⁣⁤    applied to:
   8                      ⊢     # ‎⁤⁡      8 and right argument,
     16                   ⊢     # ‎⁤⁢      16 and right argument,
‎⁤⁣
# ‎⁤⁤‎⁤⁢To Summarize:
# ‎⁢⁡⁡‎⁤⁣  monadic version returns: [arg, oct(arg), hex(arg)]
# ‎⁢⁡⁢  dyadic version returns: [left + right, oct(right), hex(right)]
‎⁢⁡⁣
⊃   # ‎⁢⁡⁤pick first (extracts the current count)
    # when snippet is repeated this would be in front of all the dyadic calls
    # but not in front of the final monadic call

 1  # ‎⁢⁢⁡The initial count
💎
added 2587 characters in body
Source Link
Mukundan314
  • 12.7k
  • 1
  • 16
  • 58
Loading
deleted 20 characters in body
Source Link
Mukundan314
  • 12.7k
  • 1
  • 16
  • 58
Loading
Source Link
Mukundan314
  • 12.7k
  • 1
  • 16
  • 58
Loading