« first day (4388 days earlier)      last day (454 days later) » 

12:13 AM
0
Q: Yakko's New World Order

97.100.97.109Given a list of countries in alphabetical order, put them in the same order as they are given in the song "Yakko's World". Specifically, you are given the following list of countries* exactly: Abu Dhabi, Afghanistan, Albania, Algeria, Algiers, Angola, Argentina, Australia, Austria, Bahamas, Bahra...

 
12:47 AM
0
Q: "Hello, World!" but with a twist :)

undefnedYour goal is to print "Hello, World!" ... while only being able to use a letter only once. The Rules You must print "Hello, World!" You can only use each letter once. ... that's it. Note: This might be impossible in some languages, for obvious reasons.

 
@NewPosts If not duplicate then not that bad
 
 
1 hour later…
2:12 AM
Any processor allow interrupting during an instruction and store immediate states into stack, maybe mixed with flags?
 
definitely seems doubtful but if there is one i'm quite eager to hear about it too lmao
 
 
1 hour later…
3:39 AM
@l4m2 At least in ARM (Cortex-A), only a few registers (including flag register) are swapped, and context saving is done with explicit code.
Automatically pushing things to stack might be dangerous when the interrupt source can be memory fault by stack overflow, for example
 
 
2 hours later…
6:09 AM
What optimization do gcc -O0 do? It even convert x*3+y*3 into (t=x+y,t+t+t)
@Bubbler Maybe this more applies to standard lib, so standard that they're manufactured in ROM
although -O1 convert x*3+y*3 into (x+y)*3 using LEA
 
6:32 AM
CMC what is the shortest C program sped up by the lto option of gcc?
 
if you look through the passes it applies this should be easy enough to figure out
 
6:47 AM
@Razetime I would be very interested in the answer
 
7:18 AM
@Razetime Bracmat LOTM?
 
Is LoTM just dead at this point
 
12 answers where posted last month
So not super active not quite dead either
 
7:35 AM
0
Q: Smallest Bit Rotation

tshFor a given positive integer, try to find out the smallest possible rotation resulted by rotating it 0 or more bits. For example, when the given number is 177, whose binary representation is \$10110001_{(2)}\$: \$ 10110001_{(2)}=177 \$ \$ 01100011_{(2)}=99 \$ \$ 11000110_{(2)}=198 \$ \$ 1000110...

 
 
2 hours later…
ooh
...now i'm wondering what the hell a floretion is
 
10:32 AM
looks nice
 
 
3 hours later…
1:37 PM
so LoTM dead again?
 
yes, I think
 
 
1 hour later…
3:02 PM
Is it ok if I repeat my CMQ?
Or CMC
 
 
1 hour later…
4:10 PM
https://codegolf.stackexchange.com/questions/257325/get-the-date-of-the-nth-day-of-week-after-the-xth-day-of-week-in-a-given-year-an

someone help me understand the input format of this thing
for 2023 February Tuesday 4 Wednesday 1, is that 1st Wed after 4th Tue in Feb 2023?
or is that reversed
oh i see the input format is reversed, 2021 November Tuesday 1 Monday 1 is the 1st Tuesday after the 1st Monday in Nov 2021
 
4:32 PM
0
Q: Don't repeat yourself

Wheat WizardIn this challenge you will be tasked with implementing a sequence of natural numbers such that: Each number appears a natural number of times No two numbers appear the same number of times No two numbers appear in the sequence next to each other more than once. For some examples, the sequence 1...

 
codegolf.meta.stackexchange.com/a/25064/113573 Has a challenge like this been done before?
 
4:49 PM
i dont think so
but id suggest define variance in the post
 
5:22 PM
LDQ: should i have a separate int and float type in Rol?
 
Is Rol a praclang?
@Simd definitely, yeah, if nobody replied :P
 
5:38 PM
@mathcat yeah, ive been mentioning it here and there
its a lang that compiles to lua, just because lua has such bad syntax choices
 
@Seggan I'd say yes then
 
6:08 PM
why?
 
Idk, it makes sense when using operations for integers/natural numbers only. I don't see any disadvantage if you manage to make them compatible with each other.
 
just wanted to see your rationale :)
 
6:23 PM
@Seggan Depends on what you're using it for
And whether Lua does the same, since you're transpiling to it
If it's meant to feel like a scripting language even though it's compiled, then you could just have a single number type
 
@mathcat thank you :)
CMC what is the shortest C code the is sped up by lto (in GCC or clang)?
 
6:45 PM
a();main(){a();}a(){} but with modern compilers you might need to put a(){} in its own file to stop the compiler inlining it without lto
 
@Neil that's the problem.
Ideally I am looking for code which is faster than code compiled with -O3 just because lto is added
 
7:31 PM
well lto probably won't help for a single file in that case
you might be able to do something with a virtual function call
oh, that doesn't apply to c though
 
7:52 PM
@user lua uses floats for everything, tho the newest versions have an int type (im compiling to an older version that doesnt have it)
@user its a replacement for lua
 
@Neil if you can't get a speed up with a single file that is already very interesting
it's tempting to ask it as a challenge
 
8:15 PM
LDQ: name for implicit argument in a lambda?
im thinking either it or _
 
_1, _2, etc. to allow multiple arguments
 
map { _1.whatever() } looks weird tho
 
You have UFCS, right? You can do foo.map(whatever) then
 
yeah i have ufcs
 
8:32 PM
@user oh
oh
you are so right
 
8:54 PM
@user In that case wouldn't it make more sense to make _ a tuple
(IMO all new languages going forward should treat f(x, y, z) as calling f with a single tuple argument to make the transition to the sensible function call syntax easier)
(that being a struct with named arguments)
 
I think python-style argument passing is the best, allowing both named and positional arguments in any combination
 
Nah. I find that kinda gross ngl
I think Rust-enum-like syntax would be best
enum X {
    A,
    B(i64),
    C {
        x: i64,
        y: i64
    }
}
You can use the tuple-style call syntax where it's sensible
And the struct-style syntax where it's sensible
 
(mostly unrelated but) I think what a lot of static/strong typed languages are missing is a low-friction way to create ad-hoc static types
 
As in like, not having to do like the struct Xyz { ... } thing?
I agree
 
because you're unlikely to want to put your function's arguments into a struct (to make their meanings more explicit rather than relying on positions) if you have to declare a new struct FooArgs every time
 
9:00 PM
IMO you should be able to use a struct as a function's input or output and use that as its own type
E.g., do_foo::__input (not necessarily with that syntax ofc)
 
I guess this kinda just leads you into a type system which is structural rather than nominal
@RydwolfPrograms I'm not sure what you mean
 
Nominal type systems are good tho right? Like even for primitives (e.g., newtypes)
 
What does that example code mean?
Nominal typing is very useful for enforcing strong typing, yes, so there's the dichotomy you have to choose between
 
Like if I had a function do_foo with a signature do_foo{ bar: string, baz: i64 } -> { qux: i64, quux: i64 }, I could make a variable with { bar: string, baz: i64 } as its type (so it can be passed to do_foo, or so that I can make a variable do_quuux that uses the same input type) by using do_foo::__input as the type
 
ah so ::__input is some kind of magic operator that gets the input type of a function type
 
9:04 PM
yeah
And if you wanted to use an existing struct you'd either do do_foo BarAndBaz -> {...} or do_foo(BarAndBaz) -> {...} when declaring the function (maybe those could even be equivalent?)
What about a nominal type system that allows you to do C-style (OtherType) xyz casting for things with the same structure?
Altho I guess that specific syntax would get confusing/ugly/ambiguous with tuple types
 
@RydwolfPrograms [disagrees in Haskell]
 
@pxeger although it's not really a dichotomy: as you suggest, you can add escape hatches to a nominal system, and also vice versa - you could introduce some kind of opaque type declaration that hides a type's underlying structure
 
9:28 PM
damn
 
 
2 hours later…
11:18 PM
Well, I've done some minor code writing in VScode for maybe an hour
So far I'm not as annoyed by the autocompletion as I thought I'd be
Although I haven't actually used it yet
The thingy where the function signature appears over the top of it is nice
 
@RydwolfPrograms But then you have to create a tuple object each time (unless the compiler only pretends it's a tuple but it actually compiles to a normal Lua function?)
@RydwolfPrograms I like able to give named arguments in Python whenever I feel like it, but enforcing it would be rather annoying for functions where it's obvious what the arguments are
Especially if the function has <3 parameters
 
@user No like, you call it like a normal function, and it gives you the args to it as a tuple _
 
But you'd have to create a tuple object each time, right?
 
Not manually
 
Even if the programmer doesn't make the tuple manually, the compiler will have to generate code to make a tuple
 
11:29 PM
I don't think that's how tuples work
 
If that happens for every function call, there'll likely be a lot of overhead
 
A tuple's just two things next to each other
 
It's a whole heap-allocated object, isn't it?
 
When you call a normal function you're already passing something close enough to a tuple
@user Implementation detail
 
A mostly useless object that'll be garbage collected immediately
 
11:31 PM
IIRC in Rust, an (i64, i64) is just two i64s
Nothing on the heap
 
I don't think Lua puts stuff on the stack though
Hmm, looks like Lua doesn't have any tuples built-in, although it does let you return multiple values without wrapping them in another data structure
 
I mean for dynamic languages I don't think making a tuple in a predictable place is at all going to matter performance-wise
Assuming it's even a real tuple
And not just optimized away in 90% of cases
And wouldn't _1/_2 also have some sorta overhead?
 
If Seggan's transpiler is going to try to optimize it away, that'd be fine, yeah
@RydwolfPrograms How's that? Isn't it the same as a normal function?
 
No way is creating a tuple going to take anything more than a thousandth of the time it takes to call a normal function
I mean think about things like splat arguments, named arguments, default arguments, etc.
 
Worth an experiment
 
11:34 PM
Destructuring arguments too
 
@RydwolfPrograms Yeah, Python probably uses a data structure to pass arguments, and I'm assuming Lua does too
Okay, you've convinced me
 
@user Heart parameters? Are those new? :p
 
lol
It's when you have 2 parameters who love each other
Or 1 parameter who loves...itself?
 
@user That's why there should be tuple-style function calls and struct-style ones
Like Rust's enums (and structs, since it has tuple structs)
 
I'd like to leave it to the programmer
 
11:37 PM
Which one?
 
And have them enforce it through a linter
The one using a library, not the one making the library
 
This still leaves it to the programmer, just the one that has probably spent more time thinking about performance and readability and stuff
@user Ew
Forcing people to use tools to write code is gross
 
I do not trust library authors that much
@RydwolfPrograms You don't need a linter to write code
 
Why? Most big libraries are going to have way more thought put into them than the average program
 
You need a linter to enforce a consistent style across your codebase
Each library has its own style
 
11:38 PM
fair enough
 
If some library decides it wants to use tuples for everything and I like named arguments, I won't have any choice
 
Libraries already have the power to completely ruin readability
 
Don't give them more power
 
I think it'll be pretty clear when the tuple syntax is actually warranted
I don't think this is ever really an issue in Rust, for example
You don't see fights over whether a tuple-struct is actually the right choice somewhere, it either just doesn't matter that much or a sensible decision gets made in the first place
 
I would hate to do list.map(f: { it + 1}) rather than just list.map{ it+1 }
 
11:41 PM
Well yeah
 
Using named arguments for single-parameter stuff would be exhausting
 
Using a struct with a named argument for a single argument function is stupid
Nobody would make you do that
 
How can you guarantee that?
 
You can't, but like, why would you need to
Who's actually gonna do that
 
idk, I don't trust library authors
 
11:42 PM
And if they do, who cares
 
People who use that library
 
If you use it so often it's actually causing problems, which would be a lot (most functions get used once or twice, big deal), just make a wrapper
 
Hmm okay
 
And library authors still have to use their own code for tests and stuff
 
Some don't really bother with that
Or even with good style
 
11:44 PM
If you're library's written by someone who thinks lib.openSocket{ nameOfTheSocketToInstantiate: "a" } is a good design choice that library's probably bad anyway
 
Probably shouldn't use that sort of library tbh
But sometimes you don't have a choice
 
I think situations where:
1. You have to use a library
2. The library makes poor choices regarding which function call syntax to use
3. This actually wastes time/harms readability more than the tiniest amount
will be fairly rare
Compare that to the advantages of having structs-for-function-calls and IMO they clearly outweigh the downsides
 
Fair enough
 

« first day (4388 days earlier)      last day (454 days later) »