What are you working on Sup Forums?
Last thread
/DPT/ - Daily Programming Thread
2D game engine in C++ with SFML and Lua.
>C++
Bad
>SFML
lol
>Lua
Fucking cancer
Kill yourself
off yourself retard
C++ and lua is always painful. Especially if you write the bindings by hand.
Working on my Lisp library in C.
I need a way to deal with memory leaks of the resulting program. I should also probably take a look at a JIT library.
If you have any tips or experiences please tell me.
>Lua user calling others retards
What's wrong with C++?
Nothing.
It is a slow to compile and implement mess that tries to do everything but ends up doing nothing well.
>2D game engine
Sure, another one I guess
>in C++
Nice if done right
>with SFML
Ok? Really? Why would you write an engine then?
>and Lua.
Into the trash.
What's wrong with Lua? Besides things like array indexes starting from 1.
>What's wrong with Lua?
What's the point of lua?
>to be easier to work with
Turns out that there's no real reason to use Lua if you're interacting with anything else.
If you really want stuff like dynamic code reloading or whatever for the engine just do something like this:
blog.molecular-matters.com
And now anyone can just generate a suitable DLL and everything works fine.
Lua is pointless for this purpose. Same as any scripting language really.
Absolutely nothing.
It is yet another useless language that serves no purpose. Want plug-ins? dynamic loading. Want scripting? Scheme/bash/whatever.
Anyhow, read this github.com
tard
/dpt/ get
Global by default.
That's not even close.
God, what kind of idiot wrote that document?
Don't let that moron taint your opinion of anti-useless-scripting-language people.
another "im superior because i have to write features that should be built in myself" retard
kys
lol what?
get needs to say Java is going to be a dead language by next year
fuck java
It needs to be an interjection
dpt, extortion edition.
Java is going to be a dead language by next year
How many of you le epic haxxors have made a script to get octuples today?
post code for le script kiddies
>kys
You might as well kill yourself and fuck off back to YouTube.
Praise kek
KEK
Only if you're a fucking incompetent developer
lol
Java is going to be a dead language by next year
Kek willing
Consider eating a freshly fired bullet.
Java is dead m8
lmao
Drumpf has absolutely no chance.
Fuck java it's a piece of shit language made for poo in loos and it's going to die next year
deal with it autist
For trump
I implemented Bresenham's line algorithm in 16-bit x86 assembly, in 640x480 black and white mode. It works, but only in first octant. Pixel data is written directly into video segment memory, int 10h isn't used.
Pic related - a triangle drawn using three lines.
Now I should make it work in all octants.
Get for D
Nothing.
Just fucking around on Sup Forums
C is a waste of time.
Fuck java it's a piece of shit language made for poo in loos and it's going to die next year
no lives matter
trump is going to win
nope
...
:^)
>0 posts about programming anything
>bazillion posts about "muh language is butter than ur language"
How embarrassing.
Why should I learn a scripting language like Python/Ruby/Lua/PHP/Javascript when I can program is something like C/C++/Java/C#? Scripting languages seem so pointless unless you want to make something rough and ready.
You must be new here.
But that's what Sup Forums is for.
Separate data from implementation.
If you don't see a reason to learn one then don't learn one, simple as that.
>unless you want to make something rough and ready
They don't have much advantage over a compiled language in this regard. It's not like it takes more than a fraction of a second to compile and run.
Are you implying that compiled languages don't do this as well?
Can someone tell me about job references? The one I'm applying to asked me to provide them with a couple after the interview. I have no idea what this involves and how I should handle it.
You call your previous employees and ask them for a reference, that's it.
Sounds pretty cool. I've barely learned about nodes and linked lists in C++, and I have no idea what to do with them.
So you can deal with code that people have written in languages like Python/Ruby/Lua/PHP/Javascript.
You're asking for reasons why you shouldn't learn something as if there's ever a reasonable excuse.
Ask them for a reference? This isn't the same thing as a letter of recommendation, right? I get their contact information then my new potential employer will contact them?
What kind of questions can they ask? A lot of the freelance clients I've had are western Europeans living in the states who speak poor English.
Need some help with Database Design.
So far I have picture related, it's basically a Database to keep track of Inventory and Purchases.
I wanted to also keep track of how many of each item is sold in a Purchase. What should I do to achieve that?
The Quantity field in the Item table is used to keep track of how many of that Item is in the Shop's Inventory. Should I create a Inventory table to register that or it's fine this way? Should I add a Quantity field in my ItemPurchase table to know how many of each item was bought?
Turn them into templates, if you haven't already.
If you have a letter from your previous employer that contains a reference then it's all you need to hand your new employer.
Dear user Thanks a lot
You saved my day
Mm
Will do, but my problem is that I have no idea about what to do with these data structures. They're kind of hard to grasp, but I still want to do a project with them, if not anything, just so I can understand nodes and the rest better.
Make some simple pool allocator.
I don't. What should that letter contain?
I've never had an actual employer. Up till now I've only done freelance work and am finally trying to make the switch. I think I have a decent chance at this job but need the references.
Picked up the project of building a network stack in Python again.
It's something I've been wanting to do for a very long time.
I can now receive and decode Ethernet II and ARP frames
Now I have to send replies, but first I have to make an IO loop.
I'll probably use the Tornado one.
Not sure what it is, but I'll give it a go. Thanks user.
Is there anyway something could remove itself from a container in C++?
I want each enemy in my game to have a vector of every other enemy to test for collisions, but I can't think how this vector could discard the enemy holding the vector.
I'm new to programming without much experience. I'm a couple weeks into learning python and I would like to add C to my study plan.
In the /sqt/ I asked for a book that would help me learn C and not assume any prior programming knowldege. I only got one serious reply and they suggested I buy a rasberry pi and install riscos to learn BASIC. Is that reasonable advice? Is there a better way or a book that fits my criteria?
I'd go with either "C Programming: A Modern Approach", or "Pointers on C". Although, I believe the second one assumes a tad bit of programming knowledge.
plz senpai
I want one like that but I'm too much of a lazy shit to write it myself
>Should I add a Quantity field in my ItemPurchase table to know how many of each item was bought?
Yep, that's the easiest way to do it.
Just a recommendation: don't give all of your tables the same primary key name.
Instead of 'id' everywhere, use ItemID, PurchaseID, etc.
It's easier to write queries later.
I'll contact you in a year, or two when it's done. :3
yesterday someone posted a "challenge" to calculate the sum of the multiples of 3 and 5 up to 1000 (exclusive)
let's make it harder:
find the sum of the multiples of an arbitrary amount of numbers up to an arbitrary bound (exlusive)
you may disregard overflows
In that case, yes, you'd just want to add another field to ItemPurchase.
I'm assuming you're doing an incredibly simplified web-store app?
here's my own solution, in Ocaml
no peeking
let removeDupes list =
List.fold_right (fun e acc -> if List.mem e acc then acc else e::acc) list []
;;
let rec power list =
match list with
| [] -> [[]]
| car::cdr -> (List.map (fun l -> car::l) (power cdr))@(power cdr)
;;
(*not me*)
let rec gcd a b =
if b = 0 then a else gcd b (a mod b);;
(*not me*)
let lcm a b =
(a * b)/(gcd a b)
;;
let leastCommonMultiple list =
List.fold_right (fun e acc -> lcm e acc) list 1
;;
let sumOfMultiplesUpTo list bound =
let lcm = leastCommonMultiple list in
let actualBound =
let a = float_of_int (bound - 1) in
let b = float_of_int lcm in
let quot = int_of_float (floor (a /. b)) in
quot in
let naturalsSumTo n = (n*(n+1))/2 in
lcm * (naturalsSumTo actualBound)
;;
let sumOfMultiples list bound =
if List.length list = 0 then invalid_arg "There's nothing to be summed" else
let powerset = power (removeDupes list) in
let ordered =
let len = List.length in
let cmp l1 l2 = if len l1 > len l2
then 1
else if len l1 < len l2
then -1
else 0 in
List.sort cmp powerset in
let final = List.tl ordered in
List.fold_left
(fun acc e ->
if (List.length e) mod 2 = 0
then acc - (sumOfMultiplesUpTo e bound)
else acc + (sumOfMultiplesUpTo e bound)) 0 final
;;
I'm kind of working on one myself, got as far as window-scaling (everything drawn to an internal texture that is then displayed on a specific internal sprite)
but I never understood masking (need it for interfaces)
>an arbitrary amount of numbers up to an arbitrary bound
Can you repeat the question?
Also, stop putting text in code tags, faggot. It's for code, not reddit emphasis.
A Turing machine screensaver. Just because I want one.
whats the best book for learning Go?
other tips for a new gotard appreciated too
template
int sum(int max, ArgList ... args)
{
auto total = 0;
for (int i = 0; i < max; ++i) {
for (auto j : {args...}) {
if (i % j == 0) {
total += i;
break;
}
}
}
return total;
}
Probably could've been done better.
I think he means that the function calculating the sum should accept two arguments, one being a list of divisors, the other being the upper bound of the operation, so like like for the example the function would be called like so:
calc({3, 5}, 1000)
Is that supposed to be multiples of BOTH numbers or EITHER?
Either.
Thanks for the reply, I was stuck in this for at least 2 days trying to find the right answer.
I wanted to make a stupid question and I wouldn't mind at all if bash me.
How are the fields in the ItemPurchase table will be filled? I know the Quantity field will the filled by me, but are the ItemId and PurchaseId field be filled by themselves or do I need to add the ids by myself?
It means the function should be able to accept any amount of numbers (2,3,4,5,6,7 as an example) and sum multiples of each of those numbers under some specified constant (1000, for example, would mean that you'd consider 2, 4, ..., 998 for the multiples of 2).
Multiples of either of the numbers. Remember to remove dupes (ex: sum of multiples of 3 and 5 up to 16 should only count 15 once).
>I'm assuming you're doing an incredibly simplified web-store app
Exactly. If you can, please read
I'm not sure how high we're supposed to allow the number to go. What's the data restrictions?
Here's a stab:
static long SumOfMultiplesOfAnArbitraryAmountOfDivisorsBelowAnArbitraryUpperBound(int upperBound, params int[] divisors)
{
return Range(1, upperBound - 1).Where(x => divisors.Where(y => x % y == 0).Any()).Sum();
}
Thanks senpaitachi.
My entry:
function calc(divs, bound)
local sum = 0
for i = 1, (bound - 1) do
for _, div in pairs(divs) do
if i % div == 0 then
sum = sum + i
break
end
end
end
return sum
end
assert(calc({3, 5}, 1000) == 233168, 'Something happened.')
quick question
max = 5
for i in range(0, max):
max = 10
this means the loop will run 10 times now, right?
No, the range evaluates with the 5 as param and returns the iterable object.
No
>Range(1, upperBound - 1).Where(x => divisors.Where(y => x % y == 0).Any()).Sum();
I just popped a LINQ boner.
How do I update the max range within the loop then?
my two solutions from yesterday
foo = lambda ms, n: sum({i for r in (range(m, n, m) for m in ms) for i in r})
foo = lambda ms, n: sum(i for i in range(0, n) if any(not i % m for m in ms))