« first day (4148 days earlier)      last day (991 days later) » 

00:01
Well, looks like it's starting when DLosc turns up
\o/
Welcome to the twentieth Learn You A Lang for Great Good! Today, we'll be learning Pip, a golfing language that aims to be easy to learn and use. (No, not the Python package manager. :P) During the event, feel free to post CMCs to practice Pip (PMCs), ask questions about the language, and so on.
9
An older version of Pip is also available on TIO.
Y'all want me to run through the basics of the language here, or do you want to read the docs and then ask questions?
ive been reading them they are written funly so good job
@DLosc basics please. Definitely the basics
00:08
All right, here goes
Pip works a lot like dynamically typed scripting languages such as Python, Perl, Ruby, or JavaScript.
Expressions in Pip use infix operators with precedence and associativity. The value of the final expression in the program is autoprinted: 1+2*3-4
The usual way to take input in Pip is command-line arguments. The first five cmdline args can be accessed in your program as the variables a through e: 3*a+1
A Pip program consists of a series of statements. A statement can be a command or just an expression. The most common commands are W (while), T (till), F (for-in, like Python), L (loop fixed number of times), and I (if).
Most other stuff (like printing, assignment, etc.) is done using operators. You'll want to keep the list of operators and operator precedence chart handy.
All the basic operators you know and love are there: + - * / // % for arithmetic, . for string concatenation, < <= = != >= > for comparison, & | ! for logic. And there are also many, many more.
The main data types are Scalar (string/number), List, Pattern (regex), and Block (function). There's also Range (mostly used for integer sequences--you can usually pretend it's a List) and Nil (non-value, used in a lot of error conditions like dividing by zero).
"String" is a string literal; 'x is a single-char string literal. Pattern literals are surrounded in backticks (I'm not gonna fight the chat formatting to try to get those right).
Lists are multiple expressions in square brackets. No separator is necessary unless leaving it out causes a parsing problem, in which case you can use ;.
The default output format for Lists is to concatenate all their items together--often good for golf, but bad for readability. Try adding the -p flag for more legible output. There are lots of other flags too.
Since Scalars are both strings and numbers, Pip has a separate set of operators for string and numeric operations (rather like Perl). For example, + is addition, . is concatenation; * is multiplication, X is string repetition; = is numeric equality, Q is string equality; etc.
If you pass a string to a numeric operation, it's converted to a number first: If it starts with a number, that's its value, and if it doesn't, its value is 0.
A lot of operators work item-wise on Lists. This means List operations have their own set of operators, for example AL to append one list to another.
Functions can be written as a series of statements surrounded by curly braces. All functions are variadic. The arguments can be accessed as the variables a through e, and the last statement in the function is returned: {%a?3*a+1a/2}
Simple functions can also be written as bare expressions, using _ for the first argument and B for the second: _.',.B is equivalent to {a.',.b}
Uppercase letters are used for 1- and 2-letter tokens. Runs of 3 or more uppercase letters are split into tokens every 2 letters, with the odd one out (if any) at the beginning: JWVRVUWTM is J WV RV UW TM. Lowercase letters are always separate tokens.
And that's a lot, so I'll stop there for questions and maybe a challenge or two.
How does take innput?
@DLosc how do I call these functions? Or are they just used for meta-ops/function overloads?
@emanresuA a-e
10 mins ago, by DLosc
The usual way to take input in Pip is command-line arguments. The first five cmdline args can be accessed in your program as the variables a through e: 3*a+1
you said that the first five arguments are available as a,b,c,d,e, are arguments past the first five available in any way (ex as a variable that is a list of all the arguments)?
@lyxal Function call syntax is to wrap the function and its arguments in parentheses, like ({a+b} 3 5)
@des54321 Yes, g is a list of all the arguments
@DLosc what benefits does this have over just using a and b? :)
00:21
@DLosc that's very lisp-esq :p
@thejonymyster _.',.B is two bytes shorter than {a.',.b}
@lyxal Yes
ah right, since otherwise youd be asking for the literal cmd line inputs
this language seems like about half a dozen languages got in a train crash and produced a bastard lang with features from each
i kind of love it for that
i may genuinely learn this lang lol it seems pretty great
@des54321 I stand on the shoulders of giants and steal all their ideas
10
00:23
and its even pandering to me as a javascript user :P
Wondering why dlosc is in charge
what flavor regex does it got going on :]
(not sure where to reply to ask that lol)
whatever the hell python uses I would assume
i log on and i dont make assumptions :P
because it's not PCRE but it has more functionality than JS regex
00:25
@thejonymyster It's mostly Python flavor, with a few added quirks. I'd like to have used a more powerful flavor, but I don't want to reimplement a regex engine or install non-standard packages.
i respect that yea
we all want to make regex be better but nobody wants to reprogram regex :P
@DLosc can confirm about this. Python regex is a nuisance sometimes lol
The main thing I added on top of Python flavor is that you can use & in replacements to indicate the whole match: ATO
PMC: Given n, calculate n factorial. No builtins (if it exists)
(There is no factorial builtin, BTW)
00:28
thats tricky cause i dont know how to conditionals yet :P
? is the conditional operator. It works like the one in C or JavaScript, except it doesn't need the : part. a?bc
@emanresuA Pip, 5 bytes: ATO
@lyxal damn was just working out how to write that
@lyxal Yep, that's the shortest way.
00:31
PMC: n-th Fibbonaci number given n
The $ (fold) meta-operator can be applied to any binary operator.
How do I call a function?
13 mins ago, by DLosc
@lyxal Function call syntax is to wrap the function and its arguments in parentheses, like ({a+b} 3 5)
If you have the arguments in a list, you can also do {a+b} V [3 5] (which is the only way to call a function with zero arguments, by using an empty list).
Pip, 19 bytes: a<2?1;(REa-1)+REa-2 for fibbonaci
Why doesn't this work?
00:37
@emanresuA according to putting a -w flag on it for warning youre trying to add nils together
@emanresuA Statements like I don't have return values. You'd need to use the conditional operator like des did
Oh okay
also actually 18 bytes: a<2?1(REa-1)+REa-2, didnt need the semicolon
I was just about to say that :)
@des54321 17
00:41
Hint to shave another byte: comparison operators return 1 for truthy, 0 for falsey.
ooh I like that
I like that a lot
why use ternaries when you can use python-style shortcircuiting of AND/OR :P
Hint to shave another byte: Da decrements a (like --a in C).
@des54321 In Pip, a ternary is frequently just as short or shorter, but not in this specific case.
@DLosc i get a different result for a<2|(fDa)+REa-2than for a<2|(fa-1)+REa-2
same
oh
right yeah that makes sense
(because RED is parsed as R ED)
oooooh
it has side effects
ive been trying to learn haskell recently and my brain was stuck in functional programming mode
yeah I was wondering how it'd work with side effects, but two Ds has the same effect
@emanresuA this one is very beautiful
is it just me or is ATO not working anymore?
Not just you.
PMC: fizzbuzz, 1 to input n
ಠ_ಠ
00:49
@DLosc no implicit input in Pip?
How do you mean?
DB*\, with an input of 5 doesn't produce [2, 4, 6, 8, 10]
but DB*\,a does
Is ATO down again?
Some languages would let you drop the trailing a and just automatically read the input
00:53
@lyxal Correct. There are no implicit variables in expressions.
@emanresuA Yes
how do I do input on TIO?
Try it online! doesn't seem to work
Oof, now ATO staging is down too
yeah, that's why I switched to TIO
@lyxal That's the correct way to input, but TIO has an older language version that doesn't support DB.
00:55
Alright, I'ma try and get pip running in wasm
Wish me luck
@DLosc Any external dependencies I should know about?
You can also run Pip in REPL mode at Replit
@emanresuA Nope. Just needs Python 3.8 or higher, I believe.
@lyxal Yeah. That's been fixed in recent versions too.
damn that REPL doesnt work very well, cant paste or move the cursor with arrow keys
Shift ctrl v for paste
@DLosc ... I say that, and then I try it on Replit and it throws an error. >_<
@des54321 Yeah, it's not great.
01:00
@lyxal only seems to work for me if i rightclick - paste
somebody's sabotaged the lyal
@lyxal Anyway, what were you trying to do here?
Trying to get the basis of a fizzbuzzz
Because what you've done is construct a lambda function that adds its argument to a list of numbers.
I know
01:02
I think Fi\,a{P(i%3?x"Fizz".(i%3?x"Buzz")|i)} is something close to a fizzbuzz if im doing things right, but I cant get anything working to test it
I had % it errored, tried + and realised that there's still no implicit variables
37 byte fizzbuzz: Try it online!
I once had a 33-35 byte Fizzbuzz in Pip but now I can't find it
Found it!
U,hM{"Fizz"X(!\_%3)."Buzz"X(!a%5)|a}
I think
36 bytes if it works
thank goodness I never clear my browser history :p
but that's only over 1 to 100
@lyxal Doesn't quite look like it'll work as written
@lyxal Easily changed to take input, just replace h with a
@lyxal oh string multiplication instead of if/else, that is a good one
01:08
@DLosc some variation of it worked, because I remember thinking "dang it just a few bytes long of the actual one"
Try it online! works with string multiplication, but needs !s so its still 37
@des54321 You've got six bracket characters and you can drop four of them ;)
im pretty sure i cant drop the ones surrounding each side of the . because its precedence will mess everything up
That's true on one side, but not on the other.
01:14
wait and the loop works with the P so it doesnt need {}? huh thats neat
33 bytes: Try it online!
Yep. Any loop, if, etc. that only has one statement in its block can drop the curly braces.
PMC: Given a length, output a diagonal line of that length. For example, with an input of 4:
\
 \
  \
   \
@DLosc 11 bytes Try it online!
I'm beginning to doubt the integrity of pxeger's servers
@des54321 Good--now see if you can find my 9-byte solution.
I feel like it wants to be something involving Ua but I cant quite work out what
01:28
Hint: it's a single expression, no loop involved
alternate 11-byter with -n flag: Try it online!
oh thats a good one, i forgot about that whole item-wise on lists thing
and of course that one is a 7 byter with the -n flag
Imagine not calling it vectorisation :p
01:36
@lyxal Why would I call it vectorization, it doesn't turn things into vectors :P
PMC: Output this string:
0123456789
0        9
0        9
0        9
0        9
0        9
0        9
0        9
0        9
0        9
0        9
0123456789
@DLosc arguably given that it lets you use operations that take scalars on lists, scalarization might be a more appropriate name :P
where the hell is the alphabet coming from here: Try it online!
It's the initial value of z
okay i clearly dont fully understand what im trying to do here, as the variable should get immediately set to "0123456789"
The first time through the loop, i%9 is falsey, so the zR`[1-8]`s branch gets evaluated.
oh i put my branches the wrong way around facepalm
01:46
Also, note that the output has 12 lines in total, not 10
okay whats going wrong with the last line here: Try it online!
You're joining on x assuming that it'll be the empty string, but you're also assigning 0123456789 to x ;)
oh facepalm yep
Try it online! 31 bytes, fully working
Pip golf often involves shuffling around which variables to use
@des54321 Nice! You can save some bytes by using Y
theres probably a better way to cut out the middle of the string than the regex
01:50
That too
that yank is an awesome feature, down to 26 bytes: Try it online!
@DLosc is there a similarly golfy hard version of this challenge, where the numbers increment/decrement vertically as well? :P
@thejonymyster I doubt it'll be similarly golfy, but pose it as a PMC and we'll find out :D
PMC: Output this string:
0123456789
1        8
2        7
3        6
4        5
5        4
6        3
7        2
8        1
9876543210
had to squish it sorry :P
Nah, that's good. Could be some interesting options for golfing.
01:56
Im already seeing an interesting idea with "rotating" the string "0123456789", the problem is cutting out the middle
Cheeky 21 bytes (would be 20 in modern Pip)
Even cheekier 19 bytes (18 in modern Pip)
02:11
its starting to look like a compressed string :P
also whats the change that would make it modern pip
U instead of ++
Although ++ also still works
ah right ok
02:33
PMC: Given a string find if it is a palindrome
Hmm wait nobody here?
i'm here but i dont know enough pip to solve it yet :P
I think @DLosc can solve this
pretty sure there's a builtin
a==RVa
a==Ra should work too, but TIO is complaining that R is not a unary operator
(\x -> reverse x==x)
Golf my horrid haskell.
given abc, output

abc
bca
cab
02:38
permutations
^ haskell
It is a builtin.
@des54321 well theres Q, which is string equal, surely that should help with this :P
of course it will :P
aQRVa for five bytes
Make it PMC
How are yall so very quick at golfing?
@des54321 i dont get why aQRa doesnt work :O
02:42
QR gets parsed as a single operator there
well RaQa didnt work either :o
unless thats operator precedence :P
if youre using TIO, i think TIO doesnt have unary R for reverse implemented
because R is also replace as a ternary
@RadvylfPrograms lol
02:49
Async Python is so cursed
PMC: print steps to transform input to 1, by collatz conjecture
PMC:
0
A: Sandbox for Proposed Challenges

Nobody Needs NamesLeft and Right, Spsp Style WARNING This question is written by the Spsp language creator TvoozMagnificent` and might includes severe advertising. Spsp What's Spsp? Spsp is designed to be a 2D fourth generation golfing language. What are the commands? Good question, it is in developement, and if y...

PMC:
-1
A: Sandbox for Proposed Challenges

Nobody Needs NamesRoman Numerals... But With A Twist I'm assuming you have some knowledge of roman numerals, but more is at Appendix A. Fine. What's the twist? I want it short So, I don't want to express 1 as IIIIIIIIIX, I want it I. And we are not Romans, come on... Instead, you will create a program that takes i...

I lack an example program ;-)
@des54321 Unary R is a newer addition
that surprises me honestly
@DLosc why, what was the way before it was there
RV
03:02
ko neht
m'i ni a Backwards doom
enoyna od eht CMP?
si enoyreve cigrella ot Backwards?
Yes :P
It's getting a bit late for me, so I'm going to sign off for the night. Ping me with any Pip-related questions and I'll reply in the morning. o/
o/
wasm pip is slightly not working
thats the best kind of not working
\o/ I managed to finally get writing-then-importing files into the emscripten virtual filesystem
Which means, in theory, I can run Pip
And anything python-based
I've been trying to do this for ages. Turns out all I needed was a sys.path.append
03:22
\\\\\\\\\\\\\\\\\\\\oooo////////////////////////
03:37
@cairdcoinheringaahing lmao
how would that look like..
any combination of python and haskell sounds like a recipe for something horrible
except maybe
you just use haskell's comment system
;-)
@des54321 .
@emanresuA @PyGamer0 this means, in theory, I can also run flax in wasm
wait
what's wasm
i suk
03:43
webassembly
@emanresuA .
@UnrelatedString oh...
Mar 9 at 4:34, by emanresu A
user image
@DLosc how often is the ' single char string useful? i see how it is objectively golfier but im just wondering how often you find yourself using it :P
Jan 30 at 9:09, by emanresu A
Assembly is Wednesday
@thejonymyster ive already used it in one of our PMCs today
03:51
oh!
@emanresuA yes you said that you can run anything :p
@emanresuA lol
before i go to school i would like to say that on one of the benches i successfully managed to write the url for the vyxal repo :)
hopefully someone get curious and types that into a browser
because everyone knows visiting random urls written on benches is a good idea
although i suppose the amount of damage a hacker can do from you visiting an arbitrary url is fairly small
one time i picked up a cd someone left at a gas station
(not in the store, on one of the pumps)
o/ gotta go
 
1 hour later…
@NobodyNeedsNames please don't just post noise
\o/ 1+1 works in Pip in wasm!
05:28
any more feedback on this question?
@justANewbstandswithUkraine seems like a pretty good, if fairly simple question, sequence with a closed form on the OEIS, only thing id say is your use of "maximal" in the title vs "minimum" in the body is slightly confusing
thanks for the feedback! it is "minimum", horrible typo
So... now pip wasm half works
As in works half the time
And now it's completely broken
So much for that
05:49
@emanresuA works half the time as in half of the things you want to do work or every time you use it it has a 50% chance of breaking?
50% chance of breaking, and now it's more like 100%.
Okay, now it works :) (I hope)
fingers crossed I don't have to delve into the depths of importlib.util, from which few return alive.
can I ask what are you trying to do?
like why pip+wasm lol
not pip as in the package installer, pip as in read the starboard.
@emanresuA throw some of the PMC solutions from todays LYAL at it and pray to any god you believe in that nothing breaks :P
Should be running the latest commit although it currently requires manual pulling
05:58
all i did was ask it to calculate the 100th fibbonaci number
Recursion is kinda slow
okay ATO seems to time out on that one too, so its just that recursion is a stupid way to do things in pip
Wait, ATO's back up?
it didnt give an immediate error when i clicked the button and it was doing that earlier
yeah ATO is working
@des54321 anything will time out on calculating the 100th fibonacci number recursively
That's 300 quintillion recursive calls
06:03
oh yeah fibbonaci numbers do work like that dont they, number of calls is exponential
(naively that is)
which you usually are, if youre golfing it
you could hypothetically write naive recursion but have the calls memoized
Now that I'm done with that,
PMC: Generate a nxn checkerboard. Must have two distinct values.
06:16
^ is actually quite hard, I have 15
damn thats way better than what i have, i have like 35 bytes and it doesnt work yet
-l flag provides a very nice output format for this
I like my Y{%a}MCa
definitely better ways to do this one
i do like the !*:y here though
Hm nice
And ATO's down again
Oh well, 10
PMC: ASCII-art checkerboard with # and spaces.
06:43
why isnt this working
06:53
Adapting works?
07:33
0
A: Sandbox for Proposed Challenges

pxegerDon't touch the walls! code-golf array Given a multi-dimensional non-jagged array of non-negative integers, pad it with the minimal number of zeroes so that no non-zero elements of the array are "touching the edges" of the array, in any dimension. The output must remain non-jagged and have the sa...

@SandboxPosts Wait, what's a non-jagged list @pxeger
all lists at the same depth have the same length, aka rectangular array
ok
@SandboxPosts maybe u should add more tests of multidimensionals and make them appear early
else it seems like a withAtwist probem
can ultidimensional be 1D?
@SandboxPosts why the downvote?
Examples of edge elements for 1D and 3D (like the current one for 2D) might be helpful
08:40
I think all five games would make good KOTHs
Maybe not the last one as it requires the context of the first four
Also hey I remember watching that lol
yeah
@lyxal I was thinking of koth challenges, and then I remembered the video.
I think I'll post biweekly KOTHs
Part 1:
The prize money is $100 in round 1, $300 in round 2, and $500 in round 3.
All bots tell each other how many tickets they will draw, a number between 0 and 20.
They are allowed to lie and then draw a different number of tickets.
The winner gets $100 divided by the number of tickets ordered.
Onions?
09:16
Is python a good language for KOTHs?
0
A: "Hello, World!"

badatgolfScratch, 33 bytes when gf clicked say[Hello, World!

09:33
@mathcat Definitely.
okay, I'll write an API
09:46
1
A: "Hello, World!"

badatgolfABC, 21 bytes WRITE "Hello, World!" Try it online!

10:17
0
A: Sandbox for Proposed Challenges

mathcatMoney: The Koth - Part 1 These KOTHs are based on Tom Scott's series Money, so make sure to check out his video first. Challenge: Prize draw The prize money is $100 in round 1, $300 in round 2, and $500 in round 3. All bots tell each other how many tickets they will draw, a number between 0 and ...

CMC: (Haskell) define a type and a Monad instance where you can legally define return = return . return
10:46
when will LDW start?
like when will it get scheduled
and be happening
10:57
@PyGamer0 what is ldw again
the new thing?

« first day (4148 days earlier)      last day (991 days later) »