Old thread: What are you working on, Jow Forums?
/dpt/ - Daily Programming Thread
So /dpt/, does any one of you know of a youtube channel about programming? And by that I mean someone showing interesting ideas and programs, not some faggot code artisan teaching javascript.
I can't find shit on youtube because every single fucking programming channel is some faggot talking way too loud for way too long.
And I'm talking about someone demo'ing hit he's done, not teaching yet another library/language
binge watching cppcon videos is my vice
Youtube is an awful way to get any programming-related content. It's a very inefficient way to get data across, isn't searchable, and takes way too much effort to make.
The best shit usually comes in the form of technical blog posts, but I don't have any to share in particular.
Like, other than Andreas Kling?
Bitwise was also very fun (some dane making his own programming language, compiler and CPU from scratch.)
>The best shit usually comes in the form of technical blog posts,
Spotted the haskell programmer
I want to get into virtualisation in the context of consoles but have no idea how to begin. Do I just start writing a hypervisor or something?
Technical blog posts have nothing to do with haskell.
Every programming language and niche area of programming has these.
why do you think this is an easy thing you can do
trying to figure out if it's possible to do functional programming in c++
if you have no idea you should probably do something else
it is
not really
I don't, that's why I don't know how to start.
It took me a while to come up with this so thinking of something else to do will be horrible.
>Technical blog posts have nothing to do with haskell.
blog posts are the only thing haskell programmers produce
ruby!
fact = ->(n) { n > 1 ? n * fact[n-1] : 1 }
gross
Every carrot is a vegetable, but not every vegetable is a carrot.
What a worthless post
What is Jow Forums's recommended next step after learning the basic variable types, loops, and data structures? My language is Java but I don't think it matters.
Any algorithm for right triangles packing?
I need to optimize a bunch of tiny textures at runtime.
how the fuck do i invert is_void
template // what do i do here
Either map(CallableT fn)
{
if (is_left())
return fn(m_value.left);
return *this;
}
template
void map(CallableT fn)
{
if (is_left())
fn(m_value.left);
}
class Carrot extends Root implements Vegetable, DildoCapabilityInterface {
!is_void::value
what the fuck are you doing? This isn't how you're supposed to use sfinae. you want std::enable_if.
It's completely possible, but the c++ syntax makes it a bit of chore to parse IMO.
Third time I try to learn Haskell and while I think I get the whole functional thing now (and dig it), I still think I don't, cause my programs are hella slow
That's just Haskell being lazy. Laziness completely fucks performance predictability.
do you have an example? remember haskell isn't going to be as fast as C, even with turbo autism you'd maybe get half to a third
brainlet
triangle packing is np-hard breh
I use a lot of recursion I think
I will post something, since I would like some valid and belittling criticism
This one implements Luhn algorithm
isValid :: String -> Bool
isValid n = length filtered > 1 && (mod (get_luhn_sum (reverse filtered)) 10) == 0
where filtered = filter (\c -> elem c ['0'..'9']) n
get_luhn_sum :: String -> Int
get_luhn_sum [] = 0
get_luhn_sum [x] = read [x]::Int
get_luhn_sum (x:y:rol) = rx + (if 2*ry > 9 then 2*ry-9 else 2*ry) + get_luhn_sum rol
where rx = char2int x
ry = char2int y
char2int c = read [c]::Int
it is. here's a good library that implements many functional patterns in the form of generic and (relatively) easy-to-use constexpr function objects:
boost.org
you should probably write a custom function rather than read
if you're sure the input is valid, then you can just convert the char to an int using fromEnum then add/subtract the code for '0' to adjust
also, don't do (elem c ['0'..'9']), use comparison
'0'
as you can see, i have no fucking idea
Basically no.
The best you can do is full length lectures for real courses and/or tech talks.
The kinds of videos on Computerphile can be okay sometimes but will never be as in-depth.
Also, various educational vids might be hosted by literal Ph.D.-'s, but the Ph.D. population isn't high enough to pander to that audience... There are very smart people making basic info videos for market reasons, including the diversity racket. :/
But you will pick things up over time if exposed to enough, personal experience is better until understanding advanced techniques.
Which C++ standard are you targeting, first of all?
17
i know variant exists, but seeing how shit compilers are at optimizing away 16bit size optionals into registers, i thought implementing my own type was a safer bet
Maybe Data Structures, File Processing, and using different libraries for various things.
And math, more math is always better.
(learn to make basic data structures by hand even if a library would usually be used in real life)
Okay then that makes it way easier. You can just use if constexpr instead of SFINAE.
template
Either map(Callable &&c)
{
if constexpr (std::is_void_v)
{
}
else
{
}
}
>inb4 windows 10 lol
I'm not working on win10 and C# out of my own free will.
In pic related, is there anyway to get that "Type" name in C# program? I've googled it and people only pointed out methods that get the extension but what if I want full type name? Do I really need to implement some data base that translates extensions to type?
I am too much of a brainlet to make anything more complex than the example you gave me, thanks for the help though.
then the return signature will always be either and i'd have to return a value even in the void case (which is what i want to avoid)
Thanks mate, will work on those
Am I perhaps doing something that isn't "functional"? I have had a very brief experience with prolog and the whole predicates thing reminds me of Prolog a lot
Oops, didn't notice that bit then.
Leave the return type in the signature as auto, then return nothing in the void case and return Either in the other case. if constexpr is magic and permits you to do this.
imagine having to implement a compiler for this language
thanks
(define (factorial n) (y-recur n y-recur))
(define (y-recur n func)
(if (zero? n) 1
(* n (func (1- n) func))))
There also exist alpha-combinator, beta-combinator and a bunch of others. I think some translate into let expressions and so forth... But everyone looks up the Y-combinator because of Hacker News.
(((lambda (f) ((lambda (x) (x x)) (lambda (x) (f (lambda a (apply (x x) a))))))
(lambda (f) (lambda (x) (if (eq? x 0) 1 (* x (f (- x 1))))))) 5)
Those short text labels that go with filetypes are called "type descriptions". I assume they're stored in the registry somewhere... stackoverflow.com
Thank you, I'll try that
Reminder that this is real.
...
I'm writing a Python script that needs to store certain data through executions (for example, the number of times the script has been executed). At the moment, I'm storing this data in .json/.txt files which I then re-import into the script, update, and save back again. Is there a more idiomatic/language specific/comfy way of doing this?
Rent free.
A link label requires at least 1 occurence of a non-whitespace character within brackets, and at most 999 occurences of any character within the same brackets. I'm not sure you can do this with a regex alone.
Also, I didn't note the fact that link label tags get matched. I would implement a simple parser.
Looks like I'm going to hard-depend on systemd, bois. People in this board already hate me enough.
nearly every distro has it these days and a bunch of shit depends on it, dont see an issue desu
what kind of software?
alarm and reminder kek
well, you know you can't just leave it at that now. why the fuck is a reminder app hard-depending on systemd?
how do you need systemd for this? you only need some dbus shit for notifications and timedate is easy to get. pls elaborate
I want to persist reboots.
if it's a service, then that makes sense
nobody is going to use your shitty program so i see no issue
you lost me. what is the point of that entire routine with the unix domain socket? is that just to make sure not more than one runs? you could just send a signal to any running one too to focus it and then shut down again. and what does this do over just using some db to keep events and whatever the init system in use provides for starting your thing at boot?
I'm reading CLRS and I try to implement the algorithms in Haskell (yes I hate myself).
binarySearch :: (IArray a e, Ix i, Integral i, Ord e) =>
a i e -> e -> Maybe i
binarySearch arr v = go low high
where (low, high) = bounds arr
go low high
| low > high = Nothing
| otherwise =
case v `compare` (arr ! mid) of
LT -> go low (mid - 1)
EQ -> Just mid
GT -> go (mid + 1) high
where mid = (low + high) `div` 2
thanks
I know I'll use it ;)
>what is the point of that entire routine with the unix domain socket? is that just to make sure not more than one runs?
Yes and no. Uniqueness is indeed checked by another UDS alright but I hid it with Linux Abstract Namespaces so careless users don't casually delete the socket thus leading the whole program to fail. Pic related.
The second UDS is created for IPC. It's for waking up the app with certain arguments, this enable me to avoid needlessly parsing events again in realtime. And it's more robust too. What if I miss an event by the millisecond? If I already know what the event is, I can just draw an alarm window...
The events will be serialized into binary format, when the app is first run from a shut-down, it will parse those. The app will check if some alarm or reminder is missed and deal with it.
Whenever an event is created, the app saves and serializes to a file, and creates a one-time systemd task at the user level.
I know my program sounds needlessly complex but it's actually the simplest form of idea I could generate. Although I have the tendency of over-complicating things.. IDK
>I know I'll use it ;)
sorry, i meant nobody other than you
my mistake
when you guys are looking at a crash report how do you know based on the values in the registers or whats on the stack what exactly went wrong?
>sorry
don't be, it's alright ;)
Just to clear myself
> What if I miss an event by the millisecond?
... by the time I finish invoking the app. I know it's sheer pedantry but I'd like it to be robust.
Nobody wants to fuck around with registers and stack addresses. Go get a real debugger and use debugging symbols.
binarySearch arr v = uncurry go (bounds arr)
im just looking at crash reports from vidya games and trying to use what i learned in assembly class.
i do wonder if you could skirt around the dependency by using cron... but you'd just be trading one dependency for another
Without access to source code and debugging symbols, there isn't going to be much you'd be able to figure out, unless you go the full reverse-engineering route.
so pretty much these error reports are only understandable by the devs.
Yes
What I can do, however, is create an abstract API to handle a daemon. I'm powerless beyond that.
I feel terrible depriving *BSD users already, using the Linux Abstract Namespaces and all.
Supporting cron (testing it) will be a pain in the neck, it's been deprecated since few years now.
yeah, I was thinking about @reboot, but I remembered it wasn't standard. oh well!
I did something that shouldn't be possible, /dpt/. I created a polynomial time algorithm to a problem that is widely believed to be NP-complete. I'm trying to figure out where I fucked up, but the output looks correct. What do I do next?
>rust
this explains some things
test larger sets, make sure its not relying on ub
Fucking hell, it's already complicated as it is, now imagine writing in an unreadable language!
Yes, we're software engineers. What are you going to do about it?
pic related is bullshit, but the fact people believe it is almost proof of the point
not care
wagie wagie back in cagie
post some women instead
Oh, that's great! Would you mind telling me about the latest project you worked on?
You are my rubber ducky /dpt/. I don't tend to post here but often when I have an issue I start typing out a post describing it and asking for help - usually I figure the issue out by doing so and never actually post.
Thank you.
that's sexist
>You are my rubber ducky
what
my consulting fee is 200 an hour.
Ah, I have something like that as well but sharing what you are working on also helps ;)
I worked on the iOS client for the Amazon Instant Video app. Now drop that sexist attitude.
nigger