codereport / jello

A Python script for wrapping Jellyfish (a fork of Jelly) so you can more easily play with the language.
MIT License
51 stars 5 forks source link

INVESTIGATE: How do strings work? #13

Open codereport opened 9 months ago

codereport commented 9 months ago

@c4augustus @lyxal @UnrelatedString Seeing as via streams / issues I have found some people that know about Jelly, how do strings work? Supposedly the back double quote is for characters, and an enclose front/back double quote is for strings. But for the life of me it doesn't seem to work. To check if the character A exists in string ABC:

image

but this works:

image

c4augustus commented 9 months ago

Actually, your example does work properly from the command line:

Captura de ecrã 2023-12-16, às 17 40 42

But Jelly Balls is doing its own thing to decide what is a string when entered from the JS console, which it is then probably wrapping whatever you enter inside another set of weird “...” quote glyphs when it calls jelly. Notice how it is showing Args at the bottom of each string:

Captura de ecrã 2023-12-16, às 17 44 12 Captura de ecrã 2023-12-16, às 17 44 41 Captura de ecrã 2023-12-16, às 17 44 59 Captura de ecrã 2023-12-16, às 17 45 38 Captura de ecrã 2023-12-16, às 17 46 30
c4augustus commented 9 months ago

Okay, I found the problem. It's the jelly program itself when called from a shell command-line, or through python subprocess.run as jello is doing. I noticed that in what I wrote above I was passing the arguments to the chain as part of the chain rather than input arguments as you are doing. When we do this, jelly/main.py splits up all of the characters of the input arguments into an array of individual characters that INCLUDE the quotes into a new array of isolated characters. It also puts a single character into an array of length one which fails to be found in an array of scalar characters (last example below). I am continuing to dig into this.

Captura de ecrã 2023-12-17, às 13 38 36
c4augustus commented 9 months ago

I figured out why it's not working and I have made a screen recording to explain it here: https://www.youtube.com/watch?v=rvUssFi9qQU

codereport commented 9 months ago

@c4augustus this is awesome! I am going to do a live stream focusing on strings and simplifying / fixing them in Jellyfish : )

UnrelatedString commented 9 months ago

Haven't watched the video (and sorry for the late reply), but the issue here is that Jelly doesn't parse arguments to the program the same way as it parses literals within the program: program arguments are evaluated as Python then recursively "jellified". ”ae“abc” will return 1, but since jellification treats all Python strings as strings (rather than characters), there's no way to pass a character and a string to the program e that returns 1, because there's no way to pass a single character in at all!

I actually have no idea how Jelly Balls is ending up doing that anyways in some cases, but it wouldn't surprise me if it was designed to have some way to input characters so users don't have to work around it like usual.

c4augustus commented 9 months ago

@c4augustus this is awesome! I am going to do a live stream focusing on strings and simplifying / fixing them in Jellyfish : )

I will attend if I can.

UnrelatedString commented 9 months ago

Oh, incidentally, if you ever want to drop by Jelly Hypertraining, just let a mod know and they can unfreeze it.