« first day (3980 days earlier)      last day (708 days later) » 
00:00 - 10:0010:00 - 00:00

12:00 AM
Welcome to the ninth Learn You A Lang For Great Good! Today, we'll be learning zsh, a Bourne shell derivative that's (sometimes) good for golfing. Feel free to ask questions about Zsh, post CMCs ("ZMC"s) related to the language, and just discuss the language in general. ATO (or TIO, if you're so inclined)
@RedwolfPrograms I've given up on "will this get votes?" and have switched more to "I wonder if this will get any interesting answers"
ok I have prepared some simple exercises for anyone wishing to start learning zsh
ZMC: print hello
Or "This thing I just learnt about seems interesting, bet that could make for a fun challenge"
I just don't ask questions when writing a challenge. I just think "OK, this looks interesting, no dupes, should be fine"
and sometimes people vote on my sandbox which is some positive indicator
Q: Group elements by their displacement

caird coinheringaahingConsider the array [5, 6, 8, 3, 9, 4, 2, 1, 7]. If we list how far each number has moved from it's (1-indexed*) index, we have (considering absolute distance): Array: [5, 6, 8, 3, 9, 4, 2, 1, 7] Index: [1, 2, 3, 4, 5, 6, 7, 8, 9] Dists: 4 4 5 1 4 2 5 7 2 We can then group the elements o...

12:03 AM
Some of my challenges are based on things that I've been doing by hand and wish to write into a program, and find interesting when automating
@NewPosts ID: 239999
time to FGITW and get 240000
@pxeger echo hello
dang it
can you do 2 bytes shorter?
(spoiler: yes)
12:04 AM
Ah, I was trying <<hello :/
ok, ZMC: print Hello, World!
oh, it was lowercase
12:04 AM
@pxeger echo Hello, World! : attempt it online
@Bubbler it doesn't really matter, let's be honest
@lyxal here you run into your first pitfall
strings need to be either single-word, or quoted
@pxeger next thing posted on the site will be the 240 thousandth post on the site :P
It's working though
yes, echo is a special case, because it accepts multiple words and prints them with spaces between
but I'm guessing lyxal tried <<<Hello, World! and got an error
Echo works, and <<<"Hello, World!" doesn't save anything here
12:06 AM
Ah, interesting
I assume the intended solution is better than <<<"Hello, World!"?
(did SE chat just have a major hiccup for everyone? lol)
@pxeger .... maybe
lol yeah
@user Yes, you can use backslashes to prevent things from being split into multiple words
<<<Hello,\ World!
That makes sense
12:08 AM
Ok, next exercise: An important part of Zsh golfing is (ab)use of the filesystem to store data
@Mithical yes
ZMC: create a file called stuff with any content
(you can check if you created it correctly by running ls afterwards)
codegolf.stackexchange.com/a/240000 all hail Redwolf, the 240000th post poster :P
@pxeger touch stuff?
that's a way of doing it
and arguably the most idiomatic
but there are plenty shorter!
12:11 AM
ZMC: print 240000
FGITWer wins
Wait no, that's the same length lol
@user I'm stuff
@user you can create the file without writing anything to it
and you can use > instead of >> (>> appends, but > overwrites)
@RedwolfPrograms I can't get your solution to work on any of the TIO JavaScripts, they all say g.at is undefined
12:13 AM
You don't have nano, vim, or ed on ATO? :(
1>stuff is the shortest I can get, but idk why it works lol
I can't tell if I'm piping (is that the word?) the string 1 into stuff or what
@cairdcoinheringaahing .at is a brand new shiny JS feature
try it in your browser devtools console instead
@user on the surface, it runs the command 1 and sends its output to stuff
and "send the output to" entails creating the file if it doesn't exist; this happens before 1 runs at all
The best way to try latest ES is browser console (or stack snippets)
1 is not actually a command that works, but that doesn't matter, because Zsh still creates the file before it does that
and this is also one of the other most important things about Zsh golfing: errors are mostly completely ignored
so there's no problem with 1 not working
12:17 AM
echo zsh > stuff?
although you can use :, which is a one-byte command that does actually exist
@emanresuA yep that works too, it can be anything to output to that file
Apparently 1>stuff and 1 >stuff are different
ah, I forgot about that
although they have a similar effect
ok most of what I just said is true of 1 >stuff, but not 1>stuff
either way you get an empty stuff file, yeah
Oh right, 1> and 2> are out and err, right?
12:18 AM
because 1> yeah
when > is preceded by a number, it means "pipe file decsriptor N to the file", not the command
and FD 1 is standard output yeah
But what's it throwing into stuff when you do 1>stuff? There's nothing on the left
ah, this is what I was gonna to get to
this feature has a name, but I've forgotten it, so I'll just explain it from first principles
if you use a redirection like 1>stuff or >stuff, with no command, zsh just assumes you meant cat
(so you can actually have >stuff for -1 byte, too)
and cat copies its input (which is empty - you set it on ATO) to its output, which is the file stuff
so it creates the file
12:22 AM
ZMC: Shortest code with stdout longer than the code
od, 2 bytes, outputs 0000000 + newline which is 8 bytes
od dumps a file in octal, like a crude hexdump
I had 1 2>&1
and as part of the dump, it puts byte offsets on the left of its output
so even with no input, it outputs some zeroes
12:25 AM
I had echo {1..99} :(
you could have had echo {1..9} at least lol
ok, now you've learnt about filesystem stuff, lets get on to input
ZMC: define a function called f, which does nothing but does not error
(you can do better than ato.pxeger.com/…)
Wait why did I delete that
what did it say
Just f(){}
Wait, misread the ZMC
12:29 AM
which does nothing but does not error lol
@user that's pretty close to optimal
but if you put only one command inside the function, you don't need the {}
and since : is a command, you can have f():
Wait, why does it work without the colon? Or is it being parsed differently?
@user no, that will assume the command for the body is on the next line
12:31 AM
Oh, makes sense
@user yeah, that's parsed the same as f()f, where f is never called
@user if you put f() at the end of the file, you'll get a syntax error
ZMC: define a function which takes one argument and creates a file with that name
:59951248 (context: this message said f(){1/0}) - there the 1/0 is not interpreted as a division (which is what I presume you were going for), but the filesystem path to a command. Since there is no file 1/0, it also errors
f()touch $1
@pxeger I'm going to pretend I knew that :P
lol ok
@user although you can use > again
12:36 AM
I just made it look like I was trying to do a division by zero error :P
@pxeger Oh right
@cairdcoinheringaahing you've got a good brain for CnR!
Whoo, f()>$1 looks ugly af but it's very golfy
@user Zsh in a nutshell!
nutsh when
12:38 AM
maybe I should make a golkier version of zsh and call it that
lol, nutshell would be a pretty good name for a shell
also seash
no it would nut
"Nutshell in a nutshell: we just named this shell nutshell because we wanted to name this shell nutshell and because we're nuts"
@Bubbler there is csh, which is pronounced "C-shell", or "seashell"
12:39 AM
@pxeger I say it would, fight me 😡
@user sorry I actually meant to make a terrible pun but I forgot to lol
@Bubbler ls most of the time
1 byte: e -> zsh: command not found: e
That's stderr
Does w count?
12:40 AM
yeah I guess you can use w
good one
There's a shell that's probably named after me, get gamed on nerds 😎😎😎
I forgot about it because I normally use od when I want a weird separator, because w's output isn't deterministic
i've always just thought of it as "cish"
which is exactly the same as i'd pronounce ksh so it's a good thing i've never had to talk about either of them in person
12:44 AM
sorry guys, brb
STEVE (Strong Thermal Emission Velocity Enhancement) is an atmospheric optical phenomenon that appears as a purple and green light ribbon in the sky, named in late 2016 by aurora watchers from Alberta, Canada. According to analysis of satellite data from the European Space Agency's Swarm mission, the phenomenon is caused by a 25 km (16 mi) wide ribbon of hot plasma at an altitude of 450 km (280 mi), with a temperature of 3,000 °C (3,270 K; 5,430 °F) and flowing at a speed of 6 km/s (3.7 mi/s) (compared to 10 m/s (33 ft/s) outside the ribbon). The phenomenon is not rare, but had not been investigated...
I love that this is a thing
It's always hilarious when scientists make a legitimate discovery but then name it something silly
WIMPs and MACHOs come to mind
@user there’s also elves, pixies, trolls, gnomes, and ghosts
Upper-atmospheric lightning or ionospheric lightning are terms sometimes used by researchers to refer to a family of short-lived electrical-breakdown phenomena that occur well above the altitudes of normal lightning and storm clouds. Upper-atmospheric lightning is believed to be electrically induced forms of luminous plasma. The preferred usage is transient luminous event (TLE), because the various types of electrical-discharge phenomena in the upper atmosphere lack several characteristics of the more familiar tropospheric lightning. Transient luminous events have also been observed in far-...
Mathematics has the hairy ball theorem, the ham sandwich theorem, tits groups, etc. :P
I remember there were two researchers with last names (don't remember what exactly they were rn) who came together to make a thing solely so they could name their device or whatever it was something juvenile
I think one of them was Coq or something like that?
12:50 AM
The Cox–Zucker machine is an algorithm created by David A. Cox and Steven Zucker. This algorithm determines whether a given set of sections provides a basis (up to torsion) for the Mordell–Weil group of an elliptic surface E → S, where S is isomorphic to the projective line.The algorithm was first published in the 1979 article "Intersection numbers of sections of elliptic surfaces" by Cox and Zucker and was later named the "Cox–Zucker machine" by Charles Schwartz in 1984. The name is a homophone for an obscenity, and this was a deliberate move by Cox and Zucker, who conceived of the idea of...
Oh yeah
Peak comedy right there
Yeah, Coq comes from someone whose last name was Coquand or something
The guy's name was Cox (the one who made the machine, I mean, not the language)
and it's chicken
> The name is a homophone for an obscenity, and this was a deliberate move by Cox and Zucker, who conceived of the idea of coauthoring a paper as graduate students at Princeton for the express purpose of enabling this joke, a joke they followed through on while professors at Rutgers five years later.
Wow, now that's real commitment :P
12:51 AM
My surname can be made into something obscene if you try, and I kinda want to do a similar thing if I ever go into research :P
Find yourself a Coq and prove a bunch of dirty theorems together :P
someone downvoted AoCG 19 (which I posted)!
@pxeger that's not cool
if there wasn't a chance of getting in trouble, I'd upvote it with my sock acc
why would you even do that though, votes are a way to rate content so if smth gets downvotes that doesn't mean it has to get pity upvotes in return
@pxeger Any more ZMC's by the way?
Yeah, I have one or two downvotes on my challenges pretty often and I just accept the fact that some people don't like whatever things
@OldSandboxPosts Gotta love Your Challenge, Challenge:, Definition
Huh, I realised I don't remember the last time I got a downvote
@OldSandboxPosts people making it hard to antonym today
1:03 AM
@cairdcoinheringaahing September 6, according to my rep graph
I got one downvote on AoCG day 13
What did the forgetful functor do for her stoner friend? She left a joint as a free object! — Yuri Sulyma Jan 14 '15 at 3:00
Mathematical goals: to have a good enough understanding of the topics so that this is funny :P
Sounds like a mistranslation :P
1:27 AM
@cairdcoinheringaahing And of course Arnauld cuts the byte count down to below a third :p
(To be fair I had under 10m to write that answer, so it was not well golfed)
1:38 AM
@user sorry, I've had small children to deal with
ZMC: quine, but without char "r" and "p"
@pxeger Use a silencer ;)
(also no need to apologize lol)
@user Well uh...
That's definitely one way to deal with small children
This is seriously not closed?
@pxeger I've found certain tablets to be effective.
1:46 AM
@RedwolfPrograms That's like...the most opinion based/needs clarity question ever
@Adám Good idea, drug 'em and throw them out the window
@Adám what meaning of tablet?
Because iPads can be an effective distraction technique
Stone tablets. Teach them cuneiform.
ZMC: create files for every command line argument
touch $@?
1:53 AM
that works
you can do >$@
Oh lol
Zsh is sometimes weird about where $@ automatically makes a loop and where it doesn't
but > is one of the places where it does
The quine's not easy :(
ZMC: list the contents of a directory
Simpler than ls? Or does ls do something slightly different?
1:55 AM
ZMC: quine, but without char "r" and "p"
@user I've not found a shorter quine than one which is a pretty close translation of the Python quine
@user yep, just ls will do
@Fmbalbuena I saw that the first time lol
ZMC: given a list of strings, uniquify them (output can be in any order)
@pxeger Fire is what I use.
@user can you do?
1:58 AM
please please please
@pxeger hint: the previous two ZMCs are relevant
Oh lol
That is a ridiculously cursed way to do it
Will it work if the list of strings contains names like .?
you're right, it won't work for empty strings, ., .., or strings containing null bytes
but that can be ignored I think
and if the input were integers instead of strings, you wouldn't need to worry at all
Why "index.php" was protected in esolangs.org?
1 hour later…
3:10 AM
I keep wanting to adopt small spelling reforms like "though" -> "tho" and "through" -> "thru" to do my part in making the language better, but people have too many dumb associations between "correct" english and intelligence/social class >:|
"Man, english's spelling really sucks doesn't it"
"Yeah, even tho it's not even regulated by any formal body"
"Ahem, I think you mean 'though'"
I mean we get things like "hiccup", "donut", and "miniscule", but at a terrifyingly slow rate
Like, sure, some improvements are being made, but they take more than a generation and there's likely less than one per year
Everyone should just communicate in hieroglyphs /hj
We should just drop this whole english thing and standardize on phonetic jelly
@RedwolfPrograms I think tho and thru are pretty clearly abbreviations not misspellings, even to prescriptivists
@RedwolfPrograms fewer*
(hides in a corner)
I use whichever sounds better to me
yeah unfortunately a lot of people correlate english ability with intelligence
and have their ideas of what's "correct english" when, just like pretty much any language, it's really not one single standard that everyone agrees to
3:18 AM
I feel like that contributes to a lot of people's dislike of younger generations
even french, which I think has an entity that regulates its grammar or vocabulary or whatever, has an entire region speaking a variant with noticeable differences
About 16% of the world's population speak English
@hyper-neutrino Every language (except maybe conlangs or almost-extinct languages) is like that
A lot of language have official standards
English has standards, but lots of conflicting ones
after all language is a means for communication so it should adapt to fit the changing needs of its users, not vice versa lol
3:21 AM
IMO if you want to say something, and you say it, and the people you're talking to understand what you mean, you've succeeded.
for both types of language
And if you both call it english, it's english
So I can say "teh prokyoupine shooted it's quilts at I", and if you get what I mean, that is english
3:34 AM
otoh you can still have more correct english and less correct english. That's less correct than "the porcupine shot its quills at me" because it's harder to understand
Tru's thatn't
¯\_(ツ)_/¯ What if you both speak english like that?
harder to understand relative to most english speakers
about 1/4 of english speakers are native speakers, and a decent chunk of those who learned can't be bothered learning completely perfect grammar
In terms of easiness to learn, English is one of the hardest languages - Pronunciation, grammar and spelling inconsistencies are painful
i'd argue that a good chunk of native speakers can't be bothered to learn completely perfect grammar
idk where better to ask this than here but does anyone see a way to golf this (js) regex /(?<=[([{])\s+|\s+(?=[)\]}])/ just looking for whitespace immediately after an open bracket or immediately before a close bracket
ok wait let me post it on its own cause on my screen its getting split over the linefeed
the like.. \s+|\s+ in particular stands out to me as like, a redundancy, but i dont think theres a non verbose way to describe "either A before C or B after C" in regex
Yeah, that's pretty much it
3:50 AM
thanks anyway
4:23 AM
Okay, I was gonna go to bed but y'all are talking about language again so here I am =P
@RedwolfPrograms Have you by chance seen this jan Misali video? Because I just watched it the other day and you're really reminding me of it.
That's what made me bring it up lol
I just rewatched it
I think I've seen tho' with an apostrophe used by writers from a while back, maybe the 1800s, so we can claim a pretty long pedigree for that usage.
It's interesting how many successful recent spelling changes simply involve getting rid of gh: hiccup, donut, yogurt, plow. "Lite" also has some currency, but only for a subset of the meanings of "light."
Ooh, I forgot about yogurt and plow
Similarly, there are certain contexts where I expect to see "thru," particularly "drive-thru" and "no thru traffic," but I'm not sure if it will completely replace "through." Actually, similarly to tho', I think I've seen thro' in older writing sometimes.
I've seen some people with strong opinions against "donut", but I doubt anyone has too much opposition to those two (yogurt and plow)
4:31 AM
though itself is often a shorthand for although
I really like tho', I might actually try using that a few times and see how people react
I'm almost sure I'm remembering a quote from some book, maybe one of the Narnia books... "the [noun], tho' very [adjective], was very [adjective]." Can't recall the specifics, tho'.
Rgh, this is bothering me now. I think the first adjective might've been "rough"
or "plain"
Hah, well, some googling brought me instead to the journal of one Nicholas Cresswell from 1774: "Viewing the town. It is regularly laid off in squares, but very indifferently built and few inhabitants and little trade, tho' very advantageously situated..."
4:55 AM
I'm actually getting slightly inspired to seriously work on my hacking-nomic-2d-battle-royale game concept
It has a very niche target audience, but I bet if I showed it off in a few places I could find some interested people
@RedwolfPrograms The term "nomic" has me interested
I'll have to talk about it more after AoC
reminds me of the roguelite dungeon crawler mini-battle-royale concept i've had bouncing around in my head
which oddly enough was inspired mostly by minecraft
actually it's not that odd since the idea started as just
what if uhc but a full game
5:02 AM
roguelike but multiplayer?
> difficulty:impossible
So there's a term, keming, for bad kerning... I think we need to invent a term for bad OCR. Some of these Google results are hilarious.
> ... that tho very plain elderly lady nnd two uncommonly homely damsols, all tlucc drciscd Iu shabby jnourning, wcro thrco of tho greatest ladles in point.
@emanresuA Protip: lazy, by definition, doesn't guarantee when the code is actually run. So you're better off writing in the spec "don't try mixing lazy with side effects"
Probably you need a built-in that forces the lazy list to be evaluated to the end
5:18 AM
Good idea
So what happens in that code is, each iteration creates a 5-item list which contains lazy reference to the register?
will talk after aoc
1 hour later…
6:24 AM
@DLosc Oh, you mean OⱭꝚ?
Or ∝12
Or 0C12
0ptica1 Character Recogmtion
0pb'ca1 Charader Recogm'b'on
()|°t1(A1 dnarad-er recogmťø\
7:03 AM
@DLosc Okay so, I've discussed this concept a bit here before, but it's an online multiplayer game (I'm thinking a 2d battle royale), where hacking is totally allowed. There'd be no central server, everybody runs their own given other players' inputs sent from their clients. That means that you can just hack in a "rule" (e.g., a new weapon, a crate in a place there previously wasn't one, killing a player), and on your copy of the server, it would work. (1/2)
That makes it so that "reality" is kind of fuzzy; you can kill a player who's a threat on your server, but they could also just write a hack to ignore that they're dead and keep playing.
So it sort of becomes a consensus thing; if p1 thinks p2 is dead, but p2 insists they aren't ("p1" and "p2" being their servers' code, of course), then who's to say if p2 is actually alive? It'd be up to all the other players' servers/hacks, so if you do something too egregious (instead of just, e.g., giving yourself a 5% damage boost on your rifle), they can just pretend you and the kills you get never happened.
So I predict, in matches where it doesn't just instantly become chaos, people would do interesting things. They'd make weapons with unique properties, and invent slightly better items that aren't necessarily overpowered
And if you can get a bunch of other people to download your hack/mod too, you can even cobble together your own consensus features. E.g., if everyone has a mod that adds a giant potato cannon as a rare weapon, then that's just a part of the game.
If 25% of the players didn't have the mod, they'd probably just install it for that match in order to fit in
And that would also allow features like chat to be hacked in, without it necessarily being part of the original game
Ah, I mean hacking as in modifying the game's code to give you an unfair advantage, not like the game's code being intentionally difficult to decipher/modify
Like "minecraft hacks", not "hacking the CIA"
7:25 AM
Sounds like the Matrix.
1 hour later…
8:42 AM
@RedwolfPrograms that just sounds like 2b2t with extra steps :p
@flawr no, he's implying that white pixels exist, which is even shakier
@RedwolfPrograms why would you want to misspell minuscule when it has nothing to do with the mini- prefix?
9:20 AM
Anyone up for translating my JS function (f,g)=>(x,y)=>f(x,g(y)) to another language?
polyglot with proton :D
C combinator?
oh it's just D
this is equivalent to x fG} y in jelly since 2,1 in dyads does not chain
@pxeger D
in apl and bqn it's a single symbol
9:25 AM
In J it is implicit, i.e. 0 bytes: fg
K is {[f;g]{f[x;g[y]]}}
looks like the list of combinator definitions I'm referencing is largely wrong lol
I'd love to see it in say C++ and Python.
lambda f,g:lambda x,y:f(x,g(y))
C++ sounds difficult
9:28 AM
λ2|→f→λ@;†@f in Vyxal
(Don't laugh)
@Adám something like #define D(f,g)[](auto x,y){return f(x,g(y));}?
(I can never remember C++ lambdas, don't judge :Þ)
ok seems like I got K wrong
@Adám can we take arguments uncurried?
this works instead
like (f,g,x,y)=>f(x,g(y))
9:31 AM
@emanresuA sitcom laugh track plays
Simply won't be possible in a lot of golflangs
Vyxal and Jelly are exceptions, Vyxal because first-class functions and Jelly because links
@pxeger You mean taking f and g and x and y all in one go? No.
> first-class functions
talk to me when you have closures
in husk it's just ·
> comf (·) is function composition for the second argument: · f g x y means f x (g y)
@pxeger We have closures, I think
9:33 AM
do we really?
@hyper-neutrino Nice. Can I bother you to translate all of this to Python, then?
oh I guess you kinda get them for free because it's transpiled
@pxeger Nice. Can I bother you to translate all of this to C++, then?
hm maybe we do, then
@Adám iota=range, plus=lambda x,y:[x+e for e in y]
9:36 AM
isn't iota more like lambda x:list(range(x))
@pxeger Awesome. This is going into the show notes for the next arraycast.com
@Razetime It worked, though.
neat then
@Adám I demand 100% of royalties then! (just kidding; here, have an Artistic License 2.0)
Nice. Thanks!
Now for C++…
@pxeger Your license is licensed?
9:41 AM
@Adám I'm not convinced C++ is necessary
a programmer who can understand C++ but not Python would be quite hard to find
especially the kind of programmer who would listen to the array cast
OK, fair enough. I was mostly thinking because the host is a C++er.
00:00 - 10:0010:00 - 00:00

« first day (3980 days earlier)      last day (708 days later) »