« first day (2957 days earlier)      last day (1902 days later) » 

12:01 AM
hmm... @ConorO'Brien will Attache ever have *foo or **foo params?
 
Can a language be Turing complete with a do-while construct instead of a while-do?
 
@ASCII-only It has text editing capabilities to aid in writing code, but that's about it?
 
@Quintec ... since when was that about it...
did you seriously think sublime just had text editing capabilities
@ConorO'Brien where are you D:
 
@JoKing do{(if (flag) {stuff}} while (conditionmethod()); conditionmethod() {if (flag == false){flag = true} return condition}
 
no if statment
 
12:12 AM
...oh
 
think brainfuck, but the [ instruction does nothing
 
@ASCII-only I use sublime very infrequently, I'm clueless
 
@JoKing brain isn't working too well rn, but could you possibly overshoot by 1 iteration -> undo the computation of last iteration? whether you can undo will depend on the language ofc
@Quintec :|
 
found a question that doesn't really answer it
@ASCII-only possibly, but what if the iteration has an infinite loop or an irreversible (e.g. IO) operation
 
@JoKing a monad yeah that would be a problem
 
12:17 AM
sigh, i'm going to go with probably not
 
yeah it doesn't seem like you can avoid that IO operation
unless it's possible for every single operation to have no effect given the right arguments maybe. possibly.
 
@ASCII-only sick, my throat and nasal passages are committing anarchy
 
@ConorO'Brien rip :/
 
@ASCII-only that sounds fine
@ASCII-only yeah, that's a good idea, it'd need a bit of tweaking here and there... (i.e. refactoring functions to work with these things)
@ASCII-only consistency is overrated, I'll take what I like from mathematica :P
@ASCII-only it does, it's just not easy to do iirc
did I miss anything
 
a lot. but i didn't ping you for the ones you missed
oh huh. i was thinking of starting pattern matching with different numbers of arguments. could you give an example of *foo args? (since that would probably trip overloads up a bit)
@ConorO'Brien wait, nvm. the rest of the questions are on c9 probably
like... what should empty curries/lambdas look like (how many spaces inside)
 
12:28 AM
@ASCII-only I'll hop on that then, link me?
@ASCII-only yeah, gimme a sec
 
12:58 AM
Hmm. I wonder what priority overloads should have. Literal match > condition (f[x] if condition) > isinstance? Maybe isinstance > condition? And what if there are multiple args
Oh also I won't be on C9 for like the next 3-4 hours but I've stashed the changes do you can do whatever you want on c9
Re: multiple args: match as many conditions of any kind as possible? Or as many literals as possible, then as many conditions as possible, then as many subclass as possible?
 
1:44 AM
@ConorO'Brien oh also why is Array V but Hash Hash
 
1:55 AM
@ConorO'Brien also this is a problem
 
2:35 AM
@Mego can you(or another mod) unfreeze chat.stackexchange.com/rooms/88563/cicada and allow stackoverflow.com/users/11009776/dysfunctional write access to it?
 
Anonymous
@MilkyWay90 They need to visit chat before I can give them access
 
3:19 AM
@MilkyWay90 requiring a program to specify a limit on how much memory it can use means the language isn't TC; being TC means you can solve any solvable problem, even the ones where you don't know in advance how much memory you'll need
@JoKing BF where [] loops always run at least once is Turing-complete but not I/O-complete
I had a look at that language a while ago (after implementing it by mistake while trying to learn Python)
there are several possible proofs, one of the simplest is to give a compiler from a TC language to do-while BF code, e.g. this one produces code in which loops always run at least one iteration
 
3:51 AM
I wrote a mandelbrot set renderer in 245 characters of C code!

int main(){double x,y,u,v,u2,v2;int i,j,k;for(j=0;j<33;j
++){y=1.0-j*(2.0/33);for(i=0;i<80;i++){u=0.0;v=0.0;u2=u*
u;v2=v*v;x=-2.0+i*0.0375;for(k=1;k<2e3&&(u2+v2<4.0);k++)
{v=2*u*v+y;u=u2-v2+x;u2=u*u;v2=v*v;};putchar(k>=27?32:97
+k/3);}putchar(10);}}/*Fin's C Mandelbrot Set Renderer*/
 
4:45 AM
"This question has more than 500 answers already. Did you read through the existing answers first to make sure your answer will be contributing something new?" Admittedly no, but I did use the site's search feature to verify that my new answer wasn't a duplicate.
that message seems somewhat patronising when the question already has that many answers
 
5:11 AM
@ais523 Especially on the sandbox...
 
5:28 AM
"Yes, I know it has six and a half thousand answers, let me post mine"
 
@ais523 although having 500 answers is an exception on SE :P
 
5:53 AM
Wait, what question has 500 answers
 
6:03 AM
@ThePlasmaRailgun Hello, World!
 
6:26 AM
Makes sense
 
 
1 hour later…
7:46 AM
@ais523 Pretty sure I did use it for a very similar/identical CMC
@Adám I actually mentioned developing Brachylog in my CV. Don't know if it helped me get the job though
 
@Fatalize :-)
 
@Adám It seems like Matlab would fit this definition
But I wouldn't say Matlab is an APL-like language…
 
@Fatalize Apparently, it's author said it was inspired by APL.
@Fatalize No, I think I'm missing one or two more characteristics. Maybe lack of traditional precedence among operations.
CMC: Specify what makes a programming language "APL-like". Fewest number of discrete characteristics wins. Must e.g. include J and exclude MATLAB.
 
@Adám I still feel that the feel of writing and reading Matlab programs is nothing like APL
 
@Adám trains + array based operations :P
 
I've done some Matlab during my PhD, and it just feels like an array-based imperative language. APL feels like a function-combination language
 
@Fatalize Oh, I agree absolutely. I was just surprises to find he said that.
@ASCII-only Trains are surely not core to APL, as that would exclude most APLs.
 
then... short names, array-based operations :P
@Fatalize maybe they just don't understand APL that well :/
 
8:59 AM
@ASCII-only Who does tbh? :p
 
@Fatalize ○/
 
@Fatalize dzaima
 
@ASCII-only That'd make many golfing languages APL-like, no?
 
@Adám would they not be?
i guess i could be more specific re: the types of array-based operations (and/or on the definition of an array?)
 
@Adám You can compose atomic operations together, which is not the case for CJam/05AB1E
 
9:02 AM
<- has no idea what APL is like
 
@Fatalize Right. Personally, I feel that K and Jelly are APL-like, while J is an APL.
 
J is ASCII APL pretty much isn't it?
 
@ASCII-only We can fix that, but you'll have to accept UNICODE-too.
 
will J not work sure :P
after all, Charcoal is Unicode as well, i'm not severely allergic to Unicode or anything
 
@Fatalize Not entirely. The array model is slightly different (actually, dzaima/APL mostly adopts it), and it has some generalisations that no APL has adopted yet, while ridding itself of some (admittedly convenient) syntaxes that are anomalous.
@ASCII-only You can also quite easily give ASCII names to most non-ASCII symbols.
 
9:06 AM
yeah
 
@ASCII-only Well, come on over for a quick crash course!
 
9:30 AM
11
Q: Holiday Gift Exchange

SteveAnother problem from our internal golfing...this one around the holidays last year. PROBLEM Andy, Barb, Carl, Didi, Earl, and Fran are buying gifts for each other. Draw names for a gift exchange. Each person buys one gift and receives one gift. Nobody buys their own gift. Running the solution...

 
 
2 hours later…
11:17 AM
@ConorO'Brien ouch, even something as simple as a range is a pain to fully reimplement
 
-7
A: How to weight loss easily?

JamesI suggest you "The Flat Belly Fix".It is really great! This is the only 21-day rapid weight loss system that allows you to easily lose an average of 1 lb a day for 21 days without feeling hungry or deprived. The unique and brand new techniques used in this System are proven SAFE. And they do not...

lmao baited
 
12:05 PM
@LeakyNun Artificial stupidity
 
 
2 hours later…
2:31 PM
@Adám in what way? Unless you meant with ⎕boxsimple←1, my goal was to replicate Dyalogs array model
 
@dzaima I did mean that, but thought it was default/only option.
 
@Adám ⎕boxsimple←0 is the default, and the quad may disappear at any time when i feel like it as it was just an experimental test
 
2:49 PM
@dzaima The problem is that it is tying to get the value. If it instead tried to get it, it might just succeed ;-)
 
@Adám :D
 
3:50 PM
@JoKing hm, regarding BF where [ is only a marker and not a command, maybe you can somehow store the state of the previous iteration in some other place in the tape (the way to do that would differ depending on the code in the loop, of course), and, at the end, replace the current state with the previous state and then clear the area where the previous state used to reside on (don't count the last iteration, which is subtracting one iteration, converting the do-while loop to a while loop)
 
4:26 PM
0
Q: Find how "smooth" a number is based on binary

Ethan SlotaI haven't been on PP&CG for a while, so I thought I would post something! Your task is to find how "smooth" a number is. Your method is to: 1: Convert a number to binary 2: Find the number of changes / switches 3: Find the length of the string (in binary) 4: Divide length by changes So, an...

 
4:36 PM
fun little challenge.. evaluate pbs.twimg.com/media/D05nePKX4AAYY3D.png:large
 
4:49 PM
Google nixed their latex api
I wonder if I should fix all my answers that use it
 
what does nixed mean?
 
Removed
> Nix, verb (NORTH AMERICAN)
1.
put an end to; cancel.
 
CMC: Given integers a and b, answer whether a÷b has a finite or infinite number of decimals. E.g. 2÷8 is finite, 2÷7 is infinite.
 
b is coprime to 10?
not quite, c.e. 1/15
 
@primo Uh, doesn't it depend on a too? E.g. 14÷7 is finite.
 
5:00 PM
no one want to try my product :) ?
 
@Anush Your product?
 
@Adám that's a nice coding challenge!
 
@Anush Oh, I get it now. What does ∏[p prime] mean?
 
product over all the primes
if anyone can insert the picture here that would be great
I am not sure how to do that
 
@Anush lim[n→∞] ∏[1,n] ((prime(n))²+1)÷((prime(n))²–1)
 
5:08 PM
@Adám yes
but now we need code :)
 
@Anush PHP, 4 bytes: 3.31
 
@Adám really??
3.31 is definitely the wrong answer
 
@Adám that's.. a really bad approximation
 
let's say you need to be within 0.05 of the right answer
 
@Anush 3.310
 
5:12 PM
@Adám nope!
 
@Adám still way off
 
@dzaima Am I translating the formula wrongly? Try it online!
 
my code (spoiler: answer)
 
wow that's hard to read :)
 
@Adám 4 pco ⍳100 gives next prime not nth prime
 
5:15 PM
@dzaima very nice
 
@dzaima Oh, d'oh
@Anush 2.5
 
@Adám yes.. but how?
@dzaima how large a prime does your code go up to?
 
:49321924 it filters primes from 2…99, so.. first 25 :p
 
@Anush The formula has no limit other than being O(n²).
 
@Adám the mathematical formula has a limit
@dzaima oh not many at all!
 
5:18 PM
^^ and that.. (yes, the n in O(n²) is the 99)
@Anush yeah, it seems to converge quickly enough
 
the answer is indeed 5/2.. well done :)
I am intrigued by which languages give you infinite lists of primes now
 
@Adám very nice!
 
@Adám Ungolfed (Python 3): Try it online!
 
@DJMcMayhem i was fixing to ask for an algorithm, because i'm lazy, thanks for the readable solution, will do a x86-64 answer for @Adám when i get home
 
5:31 PM
There might be a more obvious way. I'm lazy too which is why I didn't try golfing
 
altho, i won't be surprised if my answer segfaults for some inputs, because the best way to get extra memory golfily is to steal from the stack.
at the same time
i dont think you can do that anyways
shrug
 
6:18 PM
i really wish i could find an excuse to use SIMD instructions (x86-64) in codegolf, but they're all 4-6 bytes long at best ):
 
@Adám Dyalog Extended, 13 bytes
 
damn you adám, you get to vectorize everything you golf :p
...how much performance can Dyalog pull, anyways
is it competitive with handwritten C for the same task?
 
@moonheart08 definitely, and (though i can't find the link rn) it can sometimes outperform simple C
 
i assume APL does an amazing job at being vectorized? :P
 
@moonheart08 surprise :p
 
6:27 PM
not. :P
It's APL's entire advertising point that it's array based, of course it translates well to vectorized code
 
they've got a blog section about the implementation of Dyalog (sadly there's not a "performance" section but it's mostly that anyways)
 
There is this. Quite hard to find
 
@Adám would it be worth learning Dyalog for high(er) performance code that is heavily vectorizable?
 
@moonheart08 Yes.
 
mk
time to find some stickers for my keys or some other good ref
@Adám i'm actually looking to replace my keyboard anyways, how good are the Dyalog APL keyboards, assuming you use one? :P
only thing that kinda bugs me about Dyalog in particular is that you need a commercial license even for OSS from what i can tell
moves to APL Orchard
 
6:44 PM
@moonheart08 pretty sure installing Dyalog doesn't prevent you from uploading your own written character masses to the internet..
 
oh, i'm a moron actually
so yes, ignore me
 
problems will come when others want to use the code as they'd have to get their license separately and you can't really give out executables
@H.PWiz oh that's a cool page i hadn't seen :D
 
7:11 PM
@moonheart08 I know the layout by heart, and I can teach it to you in an hour or so too. I personally find Dyalog's own keyboards a bit too mushy. Dyalog got me a Unicomp Model M with IBM APL layout to try it out, so that's what I use. Since then, Unicomp's APL sets was updated to be Dyalog keyboards too. Can highly recommend if you don't have people around you, as they will go deaf…
 
ha, i already have a mechanical keyboard that makes people go deaf (It belongs to my dad, however, so it's on my "to return" list)
 
@dzaima @moonheart08 Actually, if you want to give out packaged executables (i.e. fold your code and the interpreter into a single exe), you can get a commercial license with 2% royalty, so then you pay Dyalog 2% of the income your exe earns you. If that's 0, so be it.
@moonheart08 The co-worker right behind me has hearing aids (and also uses has Model M connected to one of his PCs)…
 
oh, nice, i was expecting a clause against doing something like that, so it's nice to know it doesn't exist
 
@moonheart08 You can't just go ahead and do it with the non-commercial license, but a quick email to sales@ will set you up.
 
Alright
 
7:17 PM
Code you write using Dyalog's IDE is of course yours to do with what you want, and you can even compile it using the free co-dfns compiler, and distribute the generated executable.
 
i imagine the JIT performs better than compiled, but at the same time i dont know because APL has a much less complex type system, making some JIT tricks less effective
@Adám is it possible to use APL with, say, Rust or C, via a interface?
 
@moonheart08 Which way? APL calling those or them calling APL?
 
@moonheart08 Dyalog doesn't even JIT, it's straight up interpreted
 
Rust/C -> APL
 
@moonheart08 what does arrow mean
 
7:20 PM
@dzaima oh, so the compiler does better :P
@dzaima direction of the call, in this case Rust/C to APL
 
@dzaima Dyalog actually can compile some things on the fly.
 
@Adám huh really? i thought its compilation had to be manually trigerred
 
@moonheart08 I know we are working on making APL available as a shared library. I'm not sure how easy or hard it is at this time. I'll ask.
 
@moonheart08 not necessarily, what it succeeds on is that it, being APL, can specialize different algorithms for all the built-ins and their combinations on various input data live
 
@dzaima You just have to enable it with 400⌶3 and from then everything is compiled on the fly.
 
7:24 PM
@Adám oh cool
 
because really my only main interest in APL is to help write high performance code for a specific subset of my application.
 
If it can be compiled by the internal compiler, of course.
 
The rest would perform much better in Rust :p
 
@moonheart08 if your code is ¨-free, it should perform pretty well as the interpreting overhead is a constant based on the length of the code, and the specific characters are all very fast
 
considering the code of interest is aimed at game-oriented (yet realistic) chemistry and lighting simulation, i dunno if i could avoid it :p
 
7:28 PM
Greetings, gentle citizens.
 
"¨-free" is a bit tongue-in-cheek. Really, it should be free of nested arrays. Good example.
 
@moonheart08 as long as in every linear character line there's a big size array calculated on in at least one place, it should be fne
 
Mmm. Yea i'll mark chemistry off the list of potentially heavily vectorizable
 
@moonheart08 The Stormwind Boating simulator models realistic physics, and APL certainly provides adequate performance for a full motion simulator, even on a plain laptop.
 
Lighting can stick tho, considering it's multicolor, it would benefit. a lot. (Can't trust a server to have a GPU)
@Adám is the physics simulation threaded/parallelizable?
 
7:31 PM
@moonheart08 i have no idea what's there to be heavily calculated about chemistry, but if there's a big input set I'm pretty sure you can make APL perform well
 
and hmm
@dzaima Chem for thousands upon thousands of containers is heavy :p
 
@moonheart08 thousands of thousands = doable in parallel, no?
 
mhm
which is something i want
 
@moonheart08 I don't think Stormwind uses multiple threads to compute, but Dyalog does provide facilities to use multiple processes on the fly, and if the interpreter judges it as likely to save time, it will use multiple processors in parallel. Problem is that memory speed lags behind processor speed these days, so it most often doesn't pay of to do multi-processor array computations.
 
by parallel i meant doable vectorizably
 
7:33 PM
good portion is
some, like handling adding new chems to a mixture, is not (Due to the potential to have to reallocate the container)
 
0
A: Sandbox for Proposed Challenges

Magic Octopus UrnQuinanagram You're goal for this challenge is to write a quine which outputs all characters used in your programs source-code, but in a different order. The output must contain each and every character that your original program had, however the main twist is that you will be scored on the Leven...

 
the biggest part that could do with vectorizing is permuting over the container's contents to find potential reactions that may occur
each permutation has no deps on the previous or next
 
@moonheart08 oh hmm yeah, dealing with ragged arrays isn't an easy thing in apl
 
Lighting isn't ragged luckily, so it could benefit easily
 
@dzaima In the old days, APLers were masters of working with "segmented arrays", where a Boolean mask would indicate the cutting points of a large array.
 
7:39 PM
@Adám oh god right.. doesn't make it much easier to do parallel calculation on everything though, as each subarray might need a different amount of operations
i mean maybe if the subarrays aren't that long and each needs operations done linearly one could do them step-by-step on all, but that'd probably perform worse than an ¨
 
CMC Given a Boolean list and an integer list, Return the cumulative sum, resetting the accumulator to 0 whenever indicated by the Boolean. E.g. [1,0,0,1,0,0,0,1,0,1,1,0,0] and [9,12,7,9,11,1,4,5,5,3,1,11,11] gives [9,21,28,9,20,21,25,5,10,3,1,12,23]
 
arn't those arrays identical
 
Fixed.
 
Cookies for an APL solution without ¨
 
7:46 PM
@Riker no please, don't make me lose 2 hours to another askreddit post
 
@Adám that's a beautiful challenge
 
@Adám make that a real challange, it looks fun
 
@dzaima @moonheart08 Oh, OK, will do.
 
@MilkyWay90 so, I saw that you've requested access here; are you interested in Jelly?
 
But I can do it in 5 cookie-less bytes in APL.
 
7:57 PM
well i wanna do it in x86-64
 
@Riker not sure what it is referring to
 
@dzaima @moonheart08 2D partitioned cumulative sum
 
@Adám i've got this - i could probably get rid of the ,1s but beyond that, have you got something majorly different? (yes/no, don't want spoilers)
I have this idea i want to write but no matter how many times I enter the same thing over and over again, it doesn't give the right result. :|
 
@dzaima Yes. 2÷3's length, single statement, single intermediary variable, much less "going on".
@dzaima Insanity?
 
8:09 PM
lol that
 
8:19 PM
i have to say again, that's a beautiful challenge :D
 
@dzaima Exact length of "mine".
@dzaima You do have the 5-byte solution, right?
 
@Adám I haven't even touched the idea of ¨ as i needed to get into the ¨-free mind
 
@dzaima OK, good.
 
@Adám would you call your solution better than mine? does it also use ?
 
@dzaima They are very similar. "Mine" has no parens, and doesn't use any "modern" features like dyadic -/ and . Yes, it uses compression.
 
8:27 PM
huh, how "modern" is dyadic -/?
 
@dzaima I'm not sure, but I think APL"1" didn't have it. I can ask.
 
(unrelatedly, i find it weird how incredibly ¨y is dyadic reduce. i'd imagine it'd be much more useful having it execute ⍺⍺ for each sublist instead of having it force an implicit second reduce; it'd make 2-/ longer but i'd think it'd be worth it)
 
@dzaima That's what J does for both prefix f\B and infix A f\B, so APL's +\ is +/\ in J, and 3+/ in APL is 3+/\ in J.
@dzaima The reason for this is obvious. APL didn't originally have nested arrays, and so it would be impossible to return the partitions. You had to reduce them to make the results "fit".
 
8:43 PM
@Adám ah right, damn history :|
 
@dzaima Want the traditional solution?
 
@Adám sure
wait no i maaay have another idea
 
@dzaima That was close! Whenever you're ready.
 
@dzaima Amazing to see how you are approaching the orthodox solution. Your's is shorter now, btw.
@dzaima You don't need S← any more.
 
8:54 PM
@Adám oh yep. 3 bytes shorter :D
 
and then there's me who's used to an SBCS...
 
@dzaima OK, they are completely equivalent now. The only difference is the old solution using a variable and shifting to get the deltas instead of ¯2-/
@EriktheOutgolfer ?
 
@EriktheOutgolfer i meant -3, including the previous -1
 
ooooh
because, not including the -1, it was -3 UTF-8 bytes lol
 
@EriktheOutgolfer isn't S← 4 bytes
 
8:57 PM
@dzaima hm, right
 
@dzaima Yours is actually better as ¯2-/ allows the interpreter to optimise rather than reserving double memory for original and the shifted vector.
 
@Adám ah so it was that. by some reason i skimmed over that and was thinking more about the properties of the sums
again, that was a fun challenge :D
 
@dzaima Also, your solution qualifies you as a true APLer. Are you sure we can't help you find an APL job somewhere?
 
@Adám some time in the future, maybe. When, who knows ¯\_(ツ)_/¯
I was hoping to have working code an hour after writing this. I got very distracted :P
then again, that hour of doing that challenge was probably the most fun with APL I've had (excluding when i found APL and spent forever doing simple things like 1 2 3+4 5 6 lol)
 
9:25 PM
@Adám *Dystractions
 
@Don'tbeax-tripledot Hmm, perhaps we should finish this contest out...
 
Feb 26 at 7:11, by Don't be a x-triple dot
Should we proceed to the voting for Best of PPCG? It's kinda dead already
Yeah, agreed.
But only a mod can do that.
 
Oh yeah, I guess so
 
@MrXcoder plz take your old name back :(
 
@flawr I will consider that.
 
9:36 PM
@DJMcMayhem Yeah, I need to shed some rep — it is growing on me.
 
10:18 PM
@dzaima Do you want one more?
 
@Adám not now as i'm about to go sleep, but tomorrow, sure :D
 
@dzaima OK, just stay away from the FinnAPL idiom list!
 
11:10 PM
0
Q: Is it possible to make a clamp function shorter than a ternary in JS?

Ricardo AmaralImagine this short function to clamp a number between 0 and 255: c = n => n > 0 ? n < 255 ? n : 255 : 0 Is this the shortest possible version of a clamp function with JavaScript? P.S: Not sure if it's relevant but, the 0 and 255 are not random, the idea is to clamp a number as an 8-bit unsign...

 
11:45 PM
0
A: Sandbox for Proposed Challenges

NikitaSort according to cyclic order Cyclic order on a set is a function f taking three distinct elements of a set, returning bool and having following properties: f(a, b, c) = f(b, c, a) f(a, b, c) = !f(c, b, a) f(a, b, c) && f(a, c, d) = f(a, b, d) Values of f when arguments are not distinct don...

 
11:56 PM
Would anyone here help me implement a Binary Lambda Calculus interpreter in Python? I'm kind of stuck with the fact that all the resources I've found online for it are really math-heavy and have completely unreadable implementations in PHP or Haskell
Alteratively if anyone knows a simple, readable implementation online, I'd appreciate it.
I'm a Python, Kotlin, and C person, so the PHP, Haskell, Lisp, and Scheme of all the implementations I've read so far are impossible to understand
I found a paper that describes an interpreter: pps.univ-paris-diderot.fr/~krivine/articles/lazymach.pdf
 

« first day (2957 days earlier)      last day (1902 days later) »