DennisMitchell / jellylanguage

Jelly is a recreational programming language inspired by J.
MIT License
863 stars 45 forks source link

Implemented complex combine (æj) and separate (Æj) atoms #66

Closed miles-cg closed 6 years ago

miles-cg commented 6 years ago

Motivated by https://codegolf.stackexchange.com/questions/162337/seats-in-a-finnish-cinema There were a few previous challenges where using complex numbers could have saved a few bytes also.

Based on j. and +. from J.

DennisMitchell commented 6 years ago

I'd rather use i instead of j. That way, we can use Æi for x+yj -> [x, y], Æị for [x, y] -> x+yj, and æị for the dyad you propose.

miles-cg commented 6 years ago

Sure, I only chose j since that was the letter used in J. Æị is a nice extra idea for mapping over pairs. I'll edit those in.

miles-cg commented 6 years ago

So obviously Æị would operate at ldepth = 1, and the first three cases of length 0, 1, and 2 are [] -> 0, [x] -> x. and [x, y] -> x+yj, but what if the list is longer? For example, [x, y, z] -> x+yj? and ignore the tail?

DennisMitchell commented 6 years ago

Truncating works, I think.

There's a .interpreter.py.swp file in the jelly directory. That should be removed, no?