jellylanguage icon indicating copy to clipboard operation
jellylanguage copied to clipboard

Atom/quick ideas based on a Jelly corpus

Open lynn opened this issue 7 years ago • 8 comments

Putting this here, so it doesn't get lost and forgotten in the Jelly chatroom history:

I used SE Data Explorer to gather a corpus of Jelly source code lines, on which I performed some frequency analysis, resulting in

These lists gave me an idea of which common phrases deserve a 2-byte (or even 1-byte) alias. I compiled a big list of ideas for new atoms and quicks inspired by them. Feel free to comment on their merit or implementation here.

Some thoughts that came out of this in the chatroom:

  • We probably want a new chain separator for µ€, because it’s ridiculously common.
  • Ѐ and Ðf and some others should have really been one byte, but it isn’t too late to make aliases for them.
  • is by far the most common character in Jelly code, which is maybe surprising given that Jelly has automatic vectorization. We might want a 1-byte alias for S€, which comes up very often. We might also want to make a bunch of quicks that are short for “get all (blah) and map over them”, e.g. □ÐP could be short for ŒP□€.
  • Dennis considered amending the Jelly SBCS with aliases that free up more room for 1-byte monads. For example, 0xF8 could be represented by both and Ŝ, making room for a new monadic atom Ŝ while retaining backwards compatibility.

lynn avatar May 10 '18 14:05 lynn

I considered a hacky solution for mapping structures back when I added prefixes and suffixes. It would be <atom><nilad><quick> and the nilad would signal the type of structure to map over. It would be similar to ;. from J

miles-cg avatar May 10 '18 15:05 miles-cg

In that sense, a quick with syntax (A)(B)(Q), where Q is the quick, that would be equivalent to (A)€(B)/(C), where C is one of ¤$¥ corresponding to the arity of A, would be useful too, at least empirically.

GolfingSuccess avatar May 10 '18 21:05 GolfingSuccess

@GolfingSuccess Can you share some examples demonstrating how that would be useful? I'm intrigued.

lynn avatar May 11 '18 08:05 lynn

@lynn My newest example as of writing this. Dḟ0P+Ʋ⁸С€f/ can be written as Dḟ0P+Ʋ⁸Сf(Q) instead, if Q is single-byte. Oh, and, if we want (A)Ѐ(B)/(C) too, we could make (A)(B)(ÐQ). As a double-byte (Ð-) quick, I think it will lose its usefulness by a big factor.

GolfingSuccess avatar May 11 '18 11:05 GolfingSuccess

I've implemented all of the constant nilads. https://github.com/DennisMitchell/jellylanguage/commit/aeeadda652d857dbd352592ffdf723e3aada4cc4

DennisMitchell avatar May 11 '18 17:05 DennisMitchell

), Ƈ, , and Ƭ are now aliases for µ€, Ðf, Ѐ, and ÐĿ. https://github.com/DennisMitchell/jellylanguage/commit/26ac6389934006e750e2ce8a83f75f8b55578d32

DennisMitchell avatar May 11 '18 17:05 DennisMitchell

§ and Ä have been implemented as potential replacements for S€ and +\. They vectorize at depth 1. https://github.com/DennisMitchell/jellylanguage/commit/83efa29aa73907fc5e273e94c81def8f35917d04

DennisMitchell avatar May 11 '18 19:05 DennisMitchell

These atoms along with several more nilads have been added. beb17f3 Œd ( UŒD) Œḍ (ŒḌU) ŒH (œs2) œP (Ṭœp) œṖ (Ṭœṗ or Ṭk)

Here is an updated list with implemented tokens at the bottom.

dylannrees avatar May 16 '18 16:05 dylannrees