« first day (3769 days earlier)      last day (1370 days later) » 

21:01
If people like it I could pose it as a challenge tomorrow
Python has random.choices already which takes weights
@Anush APL: {?0}⍸⍨+\÷+/ Try it online!
ngn
ngn
@Anush tbh, i don't think it's particularly interesting
@Adám works with floats too!
@ngn how come?
ngn
ngn
@Anush too trivial
The alias method is pretty cool
@Adám how does it work?
@ngn is it really easy in C?
ngn
ngn
21:05
@Adám can you use multiplication instead of division and get rid of the swap?
@ngn you made my hard combinatorics challenge look trivial! :)
ngn
ngn
@Anush i don't see why it would be hard
@Anush +/ sums the weights and +\ is the cumulative sums. So dividing the cumulative sums by the sum normalises the values to be in the range (0,1] then {?0} generates a random value in the range (0,1) and finds which interval the random value belongs in.
@ngn you can make a cumulative sum array and then do binary search
ngn
ngn
@Anush i didn't make it so, i was just the first to discover that fact :)
21:07
@ngn :)
@Anush Yes, that :-)
@Adám very nice
@ngn I can: +\⍸{?0}×+/ May be more efficient too :-)
0
A: Sandbox for Proposed Challenges

4D4850Yes. Me again. However, I have an idea for a king-of-the-hill challenge. It is... Create a self-replicating program! (Subject to a few rules) Background You are a programmer who has been requested to create a self replicating program that wipes out other self-rep programs. However, you need to ha...

Got to have binary search in there!
ngn
ngn
21:10
@Adám what is []io there? (trick question)
@ngn 1 but the result is 0-indexed. Some think that should not be ⎕IO-dependent.
qwr
qwr
21:25
I've always wanted to create my own language. Anyone got any tips
btw @Giuseppe did you see this codegolf.stackexchange.com/a/226269/17360
new function notation for R that makes short functions so much shorter
@qwr get your core ideas laid out then work it out from there
@qwr First, decide what kind of language, and what implementation language you'll use.
maybe i'm not one to talk
qwr
qwr
the idea was always a Piet knockoff
lol
21:30
So a 2D language? (The fact that you store/represent the program as a picture doesn't really matter.)
qwr
qwr
I guess, but idk if there is anything unique to piet that makes the programs appear like actual Mondrain paintings
from what I can tell, many Piet programs don't look like Mondrains
well, you could think of how to enforce that then
qwr
qwr
oh yeah i remembered i joined the esolangs discord
i already forgot I did
bad memory
qwr
qwr
I don't use js but I've been learning it for work and the arrow function notation is nice
21:39
@qwr What programming languages do you use?
qwr
qwr
python mostly
and R
for code golf sometimes I'll waste a lot of time writing assembly
@qwr Maybe if instead the operation was determined both by the current block's contiguous size (and a restriction that it has to be rectangular) and its specific colour (from a fixed palette)…
qwr
qwr
R is an underrated language for code golf I think because a lot of builtins are already vectorized
APL is an underrated language because all builtins are already vectorized.
ngn
ngn
apl sales pitch coming any second :)
21:42
@ngn Ha! You're too slow.
qwr
qwr
R also has interesting "pipe" syntax, but it's not any shorter than writing functions normally
let me guess, |>
APL doesn't need a syntax for piping. Simply putting functions next to each other makes each function take the previous one's result as its argument.
qwr
qwr
well R is a funny language because Hadley Wickham and co have developed a set of libraries so widely used they're basically a dialect of R now
so piping was introduced as a very weird syntax %>%
there's even weirder syntax like %$% and %<>%
%<>% is an assignment pipe which does a pipe and assignment
as in... it tees an intermediate pipe result to a variable?
qwr
qwr
21:50
there's also a tee pipe %T>%
they actually used the letter t
qwr
qwr
the assignment pipe is like foo <- foo %>% bar is written as foo %<>% bar
there's also right assignment like x-> y because why not
and I thought haskell had weird operators!
qwr
qwr
people rarely use them
all the weird pipes I listed are not in base R
so %<>% is basically what you'd think would be %>%=
qwr
qwr
21:54
yeah but R is janky so it has two assignment operators, <- and =
(and ->)
qwr
qwr
base R has a whole swath of deprecated functions that came from S
I wonder if I can cheat in a code golf answer and say my language is R + tidyverse
and then not import the package
speaky of janky functions, I found out print in javascript will send the current page to the printer
of course
@qwr Yes, you can. Not called cheating.
22:40
Hi @lyxal
Got any more cursed Java code?
Ask hyper
They know
@hyper-neutrino Pinging you because I'm annoying
Got any nice cursed Java code?
23:24
@hyper-neutrino Y u no give user a sample of cursed Java?
Smh making me do things myself
it actually is cursed. cropping it in paint made my computer screen go black for a bit
@user
@RedwolfPrograms jokes on you because i was sleeping when you posted that
@lyxal apologies, I had to go provide sustenance to my mortal vessel
also that java code is especially cursed because the last close brace is not indented properly
fix right now or i will go over to your house and arrest you for cursedness
ight fine it's fixed
also whose code are you calling cursed
>:-(
Moderators do indeed have the power to arrest anyone in any country
> haven't tested xd
That you?
also
        pets[0] = new Pet("redwoof", "dog", "medium", 6.0, 15);
        pets[1] = new Pet("razewoof", "dog", "large", 9.0, 19);
        pets[2] = new Pet("browncat", "cat", "small", 3.0, 3);

        petCount = 3;

        doctors[0] = new Doctor("lyxal", "dog");
        doctors[1] = new Doctor("hyper", "cat");

        doctorCount = 2;
23:41
well does it work?
untested != cursed
yes
@hyper-neutrino all my other snippets work
yet they are still cursed
and besides,
12 mins ago, by lyxal
it actually is cursed. cropping it in paint made my computer screen go black for a bit
Why's the petCount needed? Doesn't Java have some sort of .length?
@lyxal that is your computer temporarily failing to handle my sheer power
23:41
@RedwolfPrograms it does, but there are null objects in the array sometimes
that sounds cursed
petCount keeps track of how many assigned pets there are
lemme guess - you're not allowed to use arraylist because assignment?
Does null mess with length?
@hyper-neutrino correct
@RedwolfPrograms not the point
23:42
yes because Java is a relatively sane language compared to JS and the .length of an array is just the number of slots it has
 pets = new Pet[MAX_PET_COUNT];
not some cursed property that can be directly modified to change the array's elements
I already know how many items there are
but I need to know how many assigned items there are
just use an array and each time you need to append an element, make a new one of size N+1 and System.arraycopy the elements over
You do know that java arrays have a fixed size right?
@RedwolfPrograms ^
23:43
oh yeah that might've been good to establish earlier

« first day (3769 days earlier)      last day (1370 days later) »