[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 309
Thread images: 23

File: 1482341897934.png (389KB, 934x1000px) Image search: [Google]
1482341897934.png
389KB, 934x1000px
What are you working on, /g/?

Old thread: >>58208426
>>
I wanted to do a very dumbed down discord clone just has a learning experience, what libraries should I use? I know c, java, c++ and python
>>
File: call.png (189KB, 1280x1388px) Image search: [Google]
call.png
189KB, 1280x1388px
Working on permissions in my VOIP protocol.
>>
File: Selection_415.png (33KB, 763x347px) Image search: [Google]
Selection_415.png
33KB, 763x347px
Learning C via the best book but I turned the assignment around because here in superior Europe we use Celsius instead of Fahrenheit.
>>
i will accept that you're a domain expert, however i feel that you haven't in any way been able to try disprove my base analysis of the economic incentives of the khronos group, and what have you.
>>
>>58213663
>What are you working on, /g/?
I'm making a reference counting garbage collector in C++ with multithread support

I have two classes working with each other. One the garbage collector class, one the abstracted primitive type. Constructor is set to increment its pointer in the garbage collector. Destructor is set to decrement its pointer. Assignment to another abstracted primitive type is set to decrement its previous pointer and increment its new pointer.

Garbage collector has a "new" function that makes the abstracted primitive type

I need this because multithread support is a bitch in C++
>>
Anyone know any decent Android tutorials/books?

I'm trying to get into Android dev, but there's tons of confusing shit going on in Android.
>>
>>58213397
You would parameterize the process type over what it returns.
>>
Which programming language should I learn if I want to become a barista?
>>
>>58214059
Haskell
>>
>>58214007
https://github.com/vhf/free-programming-books/blob/master/free-programming-books.md#android
>>
>>58214083
There's quite a few. Witch is the best to start off with?

Not that guy btw.
>>
4chan removed (You)s

here's the css to get them back

put this in your 4chan css
a.quotelink.ql-tracked:after {
content: " (You)";
}
>>
how many languages do I have to know efficiently in order to evolve into wizardry?
>>
>>58214155
11
>>
>>58214137
Which*
>>
>>58214047
And how would you prove that two such parameterized types are identical or not?
>>
Functional programming thread:

>>58214147
>>
>>58212302
In[1]:= f = <|"a.txt" -> "R", "b.py" -> "S", "c.txt" -> "R"|>;                  

In[2]:= Keys /@ GroupBy[f, Identity]

Out[2]= <|R -> {a.txt, c.txt}, S -> {b.py}|>
>>
>>58214187
Process(A) = Process(B) iff A = B

Really, a process is just a function anyways.
>>
>>58214201
IN PYTHON FAGGOT
>>
File: Capture.jpg (21KB, 407x682px) Image search: [Google]
Capture.jpg
21KB, 407x682px
Android application to share info about cultural events. Right now I'm having trouble with connecting server to this app and uploading pictures with Android, because I have no idea how to do it.

It's my engineer thesis.
>>
>>58214239
What networking library (Volley, Retrofit) do you use? Most of them support file upload.
>>
>>58214203
Are you dense or just retarded?
> A = B
This is what's not possible in general (Rice's Theorem)
>>
>>58214301
Of course coming up with a proof automatically is undecidable in general but the proofs don't have to be automatic.
>>
>>58214329
>but the proofs don't have to be automatic.
Of course they do, otherwise you could only run a fixed set of processes (and even that would be an extremely tall task to manually provide proofs for all those, it would be practically infeasible for any non-trivial process).

Hence: Trying to encode process + input as a dependent type is undecidable.
>>
>>58214412
It doesn't matter what the process is beyond its type. Even then, proving that two coinductive processes are identical/equivalent is possible with bisimulation or more generally function extensionality if the processes are just modelled as functions (which is how you can model coinductive data).
>>
>>58213783
Fix your indentation, and write in ANSI C.
>>
>>58214239
Urocza nazwa, zuchu.
>>
>>58214467
I still don't understand what defines ANSI C.
>>
>>58214290
Volley. I'm still figuring out how to store picked photo in some variable and send it to server.
>>58214482
D-dzięki. Mój promotor jest podobnego zdania.
>>
>>58214467
#include <stdio.h>
#include <math.h>

int main()
{
int c;
float f;
printf("print c to f loop in for loop\n");
for (c=0; c<=300; c+=20) {
f = (c/(5.0/9.0))+32.0;
printf("c:%i\tf:%g\n",c,f);
}

return 0;
}
>>
>>58214434
>It doesn't matter what the process is beyond its type
The value of a process very much depends on what it is.
> Even then, proving that two coinductive processes are identical/equivalent is possible with bisimulation or more generally function extensionality if the processes are just modelled as functions (which is how you can model coinductive data).
It's not possible in general (as in a general process with general input, which is what an OS would be loading and executing).
>>
>>58214506
You can supply a path to the Intent you use to start the camera app. Use that path to write the body of the multipart/form-data request in Volley.
>>
>>58214620
>as in a general process with general input, which is what an OS would be loading and executing
Why would this be the case? The processes would be precisely typed and you wouldn't even think of them as anything different from a regular term.
>>
Functional programming thread:

>>58214672
>>
>>58214520
Thank you, though I still don't understand what defines ANSI C.
>>
>>58214467
>write in ANSI C
Why the fuck would you do this without a good reason?
C99 and C11 are both supported by the only relevant compilers, GCC and Clang, and they even default to C11.
They also add a lot of useful quality of life features, especially C99.

Limiting yourself to C89 is just fucking stupid.
>>
>>58214237
not the same guy but here you go
foo = lambda f: (lambda y,g,i:y(y,g,i))(lambda y,g,i: g if len(i)==0 else (g.setdefault(i[0][1],[]).append(i[0][0]),y(y,g,i[1:]))[1],{},list(f.items()))

>>
>>58214899
how did you do that?
>>
>>58214841
only reason to target c90 is for garbage embedded compilers which is a surprisingly common c use case
>>
>>58215005
Did that anon indicate that he was writing for an embedded system with a shitty compiler?
>>
Implementing raw audio streams in my decentralized TV protocol.
>>
>>58215005
>garbage embedded
wew
we're talking about new levels of dealing with garbage
>>
>>58215014
i wasn't correcting him, just stating what i feel was an important injection
not everything needs to be an argument
>>
>>58215022
>raw audio streams
no compression? :O)
>>
>>58214899
BLEGH

foo = lambda dict: {val : [key for key in dict.keys() if dict[key] == val] for val in set(dict.values())}
>>
>>58215005
>>58214841
Other reason is supporting ancient platforms. Seems to be the reason why Vim still forbids ANSI C in their code base.
>>
>>58215089
Not enough lambda.
>>
>>58214841
>C89
Anything else is totally useless.
>>
File: Why_is_everyone_so_gay.jpg (205KB, 1280x720px) Image search: [Google]
Why_is_everyone_so_gay.jpg
205KB, 1280x720px
>>58215065
>>
File: browser #113.png (2MB, 1920x1080px) Image search: [Google]
browser #113.png
2MB, 1920x1080px
rate my clusterfuck
>>
File: opengl.png (194KB, 1920x1054px) Image search: [Google]
opengl.png
194KB, 1920x1054px
I'm reading https://learnopengl.com/ and experimenting with OpenGL and gamepad in Rust. Thanks to anon, I realized I need to convert my raw colors from sRGB to get them right, it took me like 3 minutes to find a crate that does that. Documentation for Piston/Gfx definitely could be better, something other than simple API docs would be nice.
>>
>>58215042
>i wasn't correcting him
You were pretty clearly trying to correct him. Even if that's not what you intended, that's how it came across.
>important injection
Why? It's extremely unlikely that he's targeting an embedded system, or will be in the near future.
>not everything needs to be an argument
If you're not going to defend what you say, why even say it at all?

>>58215098
I'm sure that someone new to C is targeting ancient platforms.
There are plenty of "modern" C programs that aren't fussed about ancient shit like mpv and wayland (off the top of my head) that use C99.
A don't think a lot of people have moved to C11 yet, because you still have distros like Ubuntu and Debian who ship ancient versions of GCC that don't have complete C11 support yet.
>>
>>58215060
Just for testing. Opus is going to be the default format once everything works.
>>
>>58213705
pls someone
>>
>>58215155
wow i hope i will never have to work with you
>>
>>58215151
> Rust

You may as well kill yourself now.
>>
>>58215170
Don't worry, Anon, he's clearly a lifelong NEET.
>>
>>58215156
>Opus is going to be the default format once everything works.
that's what i like to hear :3
what are you using for video compression?
h264 is probably the best bet right now due to hardware support but im excited for AV1
>>
>>58215180
rust ain't bad though
i'd wait for couple more years before bringing it into production, but it doesn't seem half that bad for whats its trying to be, i.e. a modern c with more sensible semantics
>>
>>58215170
>Goes on 4chan
>Doesn't expect an argument/debate
You're a fucking idiot.
>>
>>58215151
Way too much syntax highlighting.
>>
>>58215296
>he doesn't like his code to look like a bunch of skittles
>>
>>58215293
this is a way brutal self own
>>
>>58215180
>>58215291
I generally agree. Rust is very immature as a platform and finding libraries will be hard for several more years, but the language is quite good for what it tries to be. And you don't have to participate in the cancer that is Mozilla just because you use the language. They can get deported to the Moon for all I care, as long as more libraries are created.
>>
>>58214491
>>58214748
https://en.wikipedia.org/wiki/ANSI_C
>>
>>58214491
ANSI defines ANSI C
>>
>>58215456
Many of those later standard libraries seem quite important? Does this mean I'll have to rewrite threads.h in my application just to want to use it while still being ANSI C?
>>
>>58215542
>I'll have to rewrite threads.h
no, you use OS specific non-cross platform libraries. like a real man
>>
>>58215542
threads.h is an optional C11 feature that doesn't have wide support yet.
C99 is the standard version that adds all of the interesting shit.
>>
>>58215222
VP9 because of licensing and it is on par with h264
>>
>>58215151
I look at rust, and it seems nice, and I want to try it again, but my first experience with it was so horrible I really don't.
>>
>>58215222
>>58215593
Also, the Opus and VP9 is what WebM uses (at least the newer versions).
>>
>>58215441
right, though?
its as if wasn't c was controlled by (now nokia) bell labs beyond a few nascent years,
and the the systems and near systems programming paradigm hadn't far evolved since the era of early unix.
the cpu has evolved quite a lot since 70s and you can't, while it is excellent by every mean, plug anymore holes in c, especially considering the shit standards adaption of even 17 year old standards.
>>
>>58215558
I want to be my applications to be as portable as possible.

>>58215562
I guess my question still stands then.
So I have to basically copy and paste those libraries into my project just to be able to use them while still writing my code in C89?
Seems like a bit of a hassle.
What about sockets?
>>
>>58215619
It does not get any more portable than ansi C
>>
>>58215619
>I want my applications to be as portable as possible
What platforms are you going to be running on that prevent you from either using an external library or using #if macros?
>>
>>58215089
i'm trying to write the normal version, but without success
def foo(dict):
d = {}
for val in set(dict.values()):
d[val] = [key for key in dict.keys() if dict[key] == val]
return d



how to write the line 4 in a normal way??
>>
>>58215619
>copy and paste those libraries
That's not how it works. It requires the C standard library to have those functions implemented.
A lot of it is shit that the programmer generally can't do themselves, at least not portably.
>What about sockets?
Standard C does not have sockets.
Use POSIX C if you want that, as well as pthreads.
>>
What is the difference in size between an XZ compressed raw audio stream and FLAC?
>>
>>58215654
def foo(dict):
return {val : [key for key in dict.keys() if dict[key] == val] for val in set(dict.values())}


There's nothing abnormal about dictionary comprehensions.
>>
>>58215708
yeah that was my first step

but how do i write in a normal way without list comprehensions?
>>
>>58215707
Why don't you test it?
>>
>>58215644
I've no idea, I just want my programs to be able to run on any platform. I think it's more of a revenge of not being able to run certain windows programs that I liked, even through wine.
OSS and portability is just very important to me.

>>58215656
I'm not sure what you meant by your first line, but I guess I'd rather use POSIX C then.
>>
>>58215735
Why would you?
>>
>>58215782
fuck you

i'll wait for someone to reply
>>
>>58215802
lmao retard.
>>
>>58215782
OH I know because the homework assignment said not to use them.
>>
File: 42233472_m.jpg (120KB, 428x600px) Image search: [Google]
42233472_m.jpg
120KB, 428x600px
about to write a C++ library that reads from a certain file format and export relevant data from it as it is somewhat of a container format and I want to allow the user to specify things such as using SIMD for speedups and so on. What are some examples of some good well-designed libraries that you have used in C or C++ and what are some key practices I should take that makes you, the user, admire a libraries' interface.

Should the file be "mounted" and locked in or should the entire file just be loaded into memory? Should a prototype "visitor" object be used so the user just inherits from your ___visitor class and the entire file is just streamed in and calles the VisitFoo(...) VisitBar(...) functions of the user-provided visitor object?

Should there be some FooReader object that takes a "Foovisitor" object and reads/iterates the entire file once. Basically a callback system so it just reads through a file once with a minimal buffer and it runs these callbacks for the appropriate data type.

It's just going to Read and never write so I figure this would be a good way to organize things but how about configuring compile-time stuff? Template trait-types that configure the FooReader? This is a lot of questions at once so id rather ask "what minimal libraries are organized the best to you" so I can just collect reference.
>>
>>58215924
Policy-based through templates, using the conventions of STL.
>>
File: output.webm (486KB, 526x310px) Image search: [Google]
output.webm
486KB, 526x310px
I'm not crazy, I swear, I'm just misunderstood.
>>
>>58215924
>What are some examples of some good well-designed libraries that you have used in C or C++
FFmpeg
>>
>>58216056
are you schizo?
>>
is there a neater multi-platform way to do integer rotation.

Like some multiplatform _rotl
>>
>>58216056
what the hell am i looking at
why is that video playing in a terminal?
>>
>>58216056
Can I watch porno over ssh now?
>>
>>58216167
Not him, but he's an anon who posts here about his terminal emulator written in Rust.
He was going on about sixel support, which is a not-widely-supported way to draw images to terminals.
>>
>>58216104
Not the insane kind.

>>58216167
Video being decoded with FFmpeg and encoded in true color sixels, then the terminal renders the sixels.

Profiled it a bit and it's being slow as fuck because I'm using Lanczos to do downscaling, like 40% of the time is spent in __sinf from libm.so.

>>58216179
Yes.
>>
>>58215441
>They can get deported to the Moon for all I care, as long as more libraries are created.
The entire Rust team is SJWs or sympathizers. When Mozilla gets droned, who will handle the power transition?
>>
File: output.webm (2MB, 526x310px) Image search: [Google]
output.webm
2MB, 526x310px
>>58216179
You definitely can, that's a decent frame rate.
>>
>>58216282
The non-retarded people using the language.
>>
File: 50526320_p0.png (486KB, 600x800px) Image search: [Google]
50526320_p0.png
486KB, 600x800px
What are the best frameworks for Bayesian inference in any language.
>>
>>58216306
>>58216056
why are great programmers retard weeboo faggots?
>>
>>58216443
litteral autism.
>>
>>58216443
I like the song in that video, and it's one of the few videos I have locally on my dev machine.

It's also pretty good for testing color accuracy because it goes bonkers towards the middle with a lot of hue shifts.
>>
In C I have implemented vector.
struct vector {
uint type_size;
uint count;
char *data;
};

Idea is you initialize it with sizeof(some_type).
When accessing data it returns (void*)(data + type_size * n)
It should work right?
>>
>>58213663
Is there a better way I could have done this in C#?
class ListHelper
{
/// <summary>
/// This method facilitates the process of converting ListBoxControl values into String List values.
/// </summary>
/// <param name="_inputListBoxControl">System.Windows.Controls.ListBox which contains the information you want</param>
/// <returns>A List of the String type</returns>
public static List<string> PeelListBox(System.Windows.Controls.ListBox _inputListBoxControl)
{

List<string> result = _inputListBoxControl.Items.OfType<string>().ToList();
return result;
}

}
>>
>>58216518
Use size_t
>>
>>58216518
yeah that basically is it
>>
>>58216521
class ListHelper
{
/// <summary>
/// This method facilitates the process of converting ListBoxControl values into String List values.
/// </summary>
/// <param name="_inputListBoxControl">System.Windows.Controls.ListBox which contains the information you want</param>
/// <returns>A List of the String type</returns>
public static List<string> PeelListBox(System.Windows.Controls.ListBox _inputListBoxControl)
{

return _inputListBoxControl.Items.OfType<string>().ToList();
}

}
>>
File: returnsorno.png (23KB, 895x366px) Image search: [Google]
returnsorno.png
23KB, 895x366px
Should I put returns here?

It will skip the rest of the statements anyway, as there is an else.

Thoughts?
>>
>>58216573
>Should I put returns here?
No
>>
>>58216521
using System.Windows.Controls;
class ListHelper
{
/// <summary>
/// This method facilitates the process of converting ListBoxControl values into String List values.
/// </summary>
/// <param name="_inputListBoxControl">System.Windows.Controls.ListBox which contains the information you want</param>
/// <returns>A List of the String type</returns>
public static List<string> PeelListBox(ListBox inputListBoxControl)
{
return inputListBoxControl.Items.OfType<string>().ToList();
}
}
>>
>>58216578
Why not?
>>
File: spec.png (46KB, 1152x648px) Image search: [Google]
spec.png
46KB, 1152x648px
>>58213663
So I've been given a project to carry out, but want to check my current thinking isn't going to be over-engineering this.

What they want, is a sort of report card for employees. Each year, the company will set criteria, based on company goals, and each employee will be ranked on each of the things, so for example an employee may rate as a 2 on productivity, but an 8 on enthusiasm (shit example).

The way they want this to be done is to highlight the relevant text for the criteria, and the program then take an average of the scores to come up with a final score. There may be several lines of criteria per box, so the whole comment may not be there.

My plan:
Java GUI
Mongo Database that holds the criteria and the scores.

Sound like a plan? Or am I overcomplicating this? They want to move away from doing this in shared excel spreadsheets.

Pic related, quickly done in paint.
>>
>>58216613
>They want to move away from doing this in shared excel spreadsheets.

For what reason?
>>
>>58216573
you must be very productive
>>
>>58216612
There is no reason to.
Putting them there isn't going to generate more efficient code.
>>
>>58216636
No idea. I think they may have had trouble with sharing it, and so want a bit more of a robust system
>>
File: howaboutnow.png (25KB, 897x420px) Image search: [Google]
howaboutnow.png
25KB, 897x420px
>>58216638
>>58216578
>>58216637
>you must be very productive
Over the past week I haven't been, but I am the last hour.

Would it be more efficient if there was code after, that I didn't need to run?
>pic related

I feel like I'm asking obvious questions, but thought I'd clarify.
>>
>>58216718
Your code is shit either way.
>>
>>58216718
Chuck that code in an else.
Compilers have control/data flow analysis that can deal with programs more complicated than that. Using unnecessary returns isn't going to make it do a better job.
>>
>>58216783
>Using unnecessary returns isn't going to make it do a better job.

Ty anon, I have maybe 5 of them in my 5k lines of code. I need to add some more, but I won't over do it.
>>
>>58216718
Why would you use italics in syntax highlighting? Would benefit would this have?
>>
>>58216797
For speed, it's definitely better to return as soon as you know you are done.

For a menu like that, probably doesn't matter at all though
>>
>>58216582
>>58216572
Fair enough. But I was actually wondering if there was a better way to convert the items from a ListBox to a List<string>.
>>
>>58216832
>return as soon as you know you are done
That's a different issue to this one.
I was talking about what a compiler would actually emit for a branch with returns at the end.
>>
>>58216843
you're not converting them, you're casting them. The items needs to be strings already in your code.
>>
>>58216858
Assembly doesn't have else at all. You either branch or you continue. I don't know how JVM bytecode does it but I suspect it's similar.
>>
>>58216831
None.
>>
Is there an Emacs theme for red colorblindness (mild protan)?
>>
>>58216613
>Fucking guy is too happy
Should be in all the boxes for all the people.
>>
>>58216928
Gouge your eyes out and learn to program blind.
>>
>>58216889
>Assembly doesn't have else at all. You either branch or you continue.
That's irrelevant. It's just about what a compiler to going to output.
With GCC (compiled with -Os),
#include <stdio.h>

int main(int argc, char *argv[])
{
if (argc < 2) {
puts("less than 2");
} else if (argc > 5) {
puts("greater than 5");
} else {
puts("between 3 and 5");
}

return 0;
}

produces
main:
.LFB0:
subq $8, %rsp
cmpl $1, %edi
jg .L2
movl $.LC0, %edi
jmp .L6
.L2:
cmpl $5, %edi
jle .L4
movl $.LC1, %edi
jmp .L6
.L4:
movl $.LC2, %edi
.L6:
call puts
xorl %eax, %eax
popq %rdx
ret

and
#include <stdio.h>

int main(int argc, char *argv[])
{
if (argc < 2) {
puts("less than 2");
return 0;
} else if (argc > 5) {
puts("greater than 5");
return 0;
}

puts("between 3 and 5");
return 0;
}

produces
main:
.LFB0:
subq $8, %rsp
cmpl $1, %edi
jg .L2
movl $.LC0, %edi
jmp .L6
.L2:
cmpl $5, %edi
jle .L4
movl $.LC1, %edi
jmp .L6
.L4:
movl $.LC2, %edi
.L6:
call puts
xorl %eax, %eax
popq %rdx
ret
>>
>>58216928
Yes
>>
>>58216437
In python, scipy and numpy.
>>
>>58216955
This is what I did; now I don't even see the code. All I see is blonde, brunette, redhead.
>>
>>58216984
>between 3 and 5
2 and 5*
That doesn't affect my point at all, though.
>>
>>58216613
Mongo database to hold 1MB of data. da fuq?

postgres:
create table employee ( id serial, name text);
create table score(year integer, employee_id integer, enthusiasm integer, productivity integer, kissass integer);


The only issue is if they want to juggle all the criteria around or change it per team or whatever. But then you spent another 10 mins next year making a new db or whatever. Processing disjoint documents in mongo isn't much more fun.

As for a gui, do some web shit in vanilla cgi with python. You'll have like 1 hit per day so it's fine. or use it as an excuse to play with async in python3.5+
>>
>>58213783
how about u indent ur code
>>
>>58217142
I don't see why this is so important.
>>
>>58217108
I guess a web page would be simpler for them, but I've never done web stuff before.

Again, mongo is something I know. The only thing is that they may have multiple bits of the criteria they want to highlight.

So for example under enthusiasm it could have under a score of 6:
1) Turns up early
2) Contributes freely
3) Helps others contribute

And highlight one or more of those.
>>
>>58217145
Why do we even bother with whitespace, aside from separating tokens? The compiler can read it, so that's all that matters.
We should all just write out programs on a single line.
>>
>>58217202
Maybe when I use a lot of brackets, I'll use indentation, but at the moment I don't see the problem. As long as it's readable and easily changed. I don't like doing markup.
>>
>>58217202
Computers are for humans to read and only incidentally for computers to execute. - Sussman.
>>
>>58217202
This. Not to mention it takes less time to compile.
>>
>>58217243
It's not readable though. Indentation is supposed to show a clear separation between different blocks and levels of code.
It's very easy to see where they start and end.
Even in your trivial example, it's not very clear.
>>
>>58217266
>Computers are for humans to read
You had one job, Anon.
>>
Why is ocaml's syntax so horrible?
>>
>>58217353
What's horrible about it?
>>
>>58217361
     let rec spower n x =
if n = 0 then .<1>.
else if n mod 2 = 0 then .<square .~(spower (n/2) x)>.
else .<.~x * .~(spower (n-1) x)>.;;

For starters everything.
>>
>>58215155

>distros like Ubuntu and Debian who ship ancient versions of GCC that don't have complete C11 support yet.

I'm on Ubuntu 16.04.1 LTS. which ships with GCC 5.4. GCC has fully supported all non-optional features of C11 since version 4.9.
>>
>>58217389
My OCaml interpreter doesn't like this
>>
>>58217419
There are still a lot of people using 12.04 and 14.04 for some reason.
Even GCC 5.4 is getting on the older side. I think that is before the point they added the nicer error messages.
>>
number = eval(input("Write a number: "))
if number <= 30 and number >= 40:
print('OK!')


How do you make it print "OK!" ? obviously not 30, anything between and 40 or above.
"30, 40" did not work either.
>>
>>58213663
Hey /g/, I'm writing an FOSS component-based game engine with event based messaging. It should be cross platform, but I will consistently be prioritizing issues which affect Linux users/developers.

Maybe you can help me with one small point. I would like to read in data from a json file and store it into an unordered_map<void*, void*>. This is going to be a very large task relative to other parts of the engine and I suspect someone must have written this already, but I can't find anything on the googlenets. Is anyone here familiar with any libraries which can do this? The solutions I've looked at so far all store the data into a special json object which isn't what I want since then I cannot have string=>obj-pointer or anything else which falls outside the json spec. Once it's loaded into memory, I no longer want to be bound by the rules of json.
>>
>>58217459
Define a new class and overload __le__ and __ge__ to always return true.
>>
>>58217478
I forgot to mention this is a C++ project.
>>
>>58217317
it's 2am. :(

if my english is like that, i dont want to know what bugs im putting in my code. ugh.

gnight.
>>
>>58217361
Seconded. For one, there are so many redundant tokens. The other thing is all those horrible symbol-character combinations like ;;.

>>58217389
Also, this.

>>58217451
My eyes don't like it either.
>>
>>58217459
It's not possible for a number to be both <= 30 and >=40. Are you sure you didn't mean to do >=30 and <=40?
>>
>>58217459
Write a number: os.system("rm -rf ~")
>>
>>58217530
Nah it's a test question. I already thought so but usually an error shows up whenever something's wrong.
This time it didn't hence I asked.
>>
>>58217389
>>58217508
>Waaaah it's not super pretty like my girlfriend Haskell
>>
>>58217478
If slurping up json is a huge consideration for you then you should probably pare down the scope of your project.

Anyway, rapidjson is plenty fast. And you can convert from the internal format to your own map with code like this (which is converting to vectors, but whatever - free code):

static void json_array_to_vector(rapidjson::Value& val, tokens_t& vec) {
using namespace rapidjson;
vec.reserve(val.Size());
for (SizeType i = 0; i < val.Size(); i++){
vec.push_back(val[i].GetString());
}
}

static void load_json(int argc, char* argv[], corpus_t& corpus, sentiments_t& sentiments) {
corpus.reserve(argc-1);
sentiments.reserve(argc-1);

using namespace rapidjson;
char readBuffer[65536];

for(int arg = 1; arg < argc; ++arg) {
Document d;
FILE* fp = fopen(argv[arg], "rb");
FileReadStream is(fp, readBuffer, sizeof(readBuffer));
d.ParseStream(is);
fclose(fp);
tokens_t tokens;
json_array_to_vector(d["text"], tokens);
corpus.push_back(tokens);
sentiments.push_back(d["sentiment"].GetInt());
}
}
>>
>>58217576
Exactly. Your girlfriend needs a facelift, Anon.
>>
>>58216306
That's some good shit, anon.
>>
>>58217459
enter "Print('OK!')"
>>
>>58217459
>>> eval(input("Write a number: "))
Write a number: print("OK!")
OK!
>>
>>58216056
>>58216306
error: no method named `dimensions` found for type `picto::view::Read<'_, picto::color::Alpha<picto::color::Rgb, f32>, u8>` in the current scope
--> src/encoder.rs:74:62
|
74 | let (mut width, mut height) = settings.size.unwrap_or(image.dimensions());
| ^^^^^^^^^^

error: aborting due to previous error

error: Could not compile `sixel`.


RIP in pepperoni.
>>
>>58217453

People need to stop using old versions of operating systems. IT should make it a point to always upgrade to the latest LTS immediately as soon as a new one is out.
>>
>>58217769
Why would IT invest money into testing and upgrading every time a new LTS build comes out rather than waiting until their current one is soon to lose support? That defeats the purpose.
>>
>>58217805
12.04 has already lost support for few years now.
>>
>>58217579
>If slurping up json is a huge consideration for you then you should probably pare down the scope of your project.
Can you elaborate on this point?

>>58217579
>Anyway, rapidjson is plenty fast. And you can convert from the internal format to your own map with code like this (which is converting to vectors, but whatever - free code):
I'll look into it. Thank you. Speed isn't a huge consideration to me since it will only affect the amount of time it takes the game to initialize. Once it is stored in an unordered_map the speed should be very fast. However, the ability to map it to another type interests me. Would that require different procedures for different json payloads or could I map all valid json with a single procedure?
>>
>>58217805

The answer, of course, should be "do it or you're fired."
>>
Finnes det ei bok skrevet på norsk som handler om Haskell?
>>
>>58217967
That would generally only be the case if there were a financial motivation behind it. In this case there would be a financial motivation working against upgrading.
>>
>>58217998

This is why we need a programmer to take one for the team, go into management, and make sure that there will be hell to pay if the developers are not working with bleeding edge development tools.
>>
>>58217533
epik /b/ro
>>
>>58218113
I was highlighting how using eval() (or any similar function in any language) is retarded.
>>
>>58218110
I'd settle for being able to use something better than SVN, and a real build system.
>>
>>58217108
So I'm going to follow this guys recommendation, and use a web interface for the criteria and postgres database.

Any tutorials you guys can recommend that will get me going with the basics?
>>
>>58218110
It just depends on what you're working on and who you're working on it for. I work for a major corporation and they give me a Macbook Pro with 2 extra 1920x1200 monitors. I have full ability to use whatever OS I want. Before the Macbook Pro I was using a Desktop with Arch Linux. I switched to the Macbook to match what my coworkers were using in order to maintain optimum compatibility. While it's true that they don't officially support the latest versions of the major operating systems, there is nothing stopping me from doing what I want as long as I get my work done.
>>
>>58218124

Outside of security concerns, there is also a great deal of performance difference between eval() and, say, parseInt(). One really should not be using eval() for this purpose.
>>
>>58217823
>support
That's not true. LTS releases are supported for 5 years. The release date of 12.04.05 LTS is August 7, 2014
>>
File: 1469840633142.jpg (36KB, 400x400px) Image search: [Google]
1469840633142.jpg
36KB, 400x400px
So I decided to write a shitty roguelike in basic python, just using the standard library.

I know there exists a really good library for this stuff in Python, but I wanted to try and do it without the library.

Getting proper formatting in the console was a bit of a pain, since literally everything is an ad hoc solution.

Rate it pls,
http://pastebin.com/Nxn7HdHs
>>
>>58218273
>Frogposter
I don't even need to open your link.
I know for 100% certainty that your code is complete garbage and that that you're a retard.
>>
>>58218273
>http://pastebin.com/Nxn7HdHs
I don't know Python but 450 lines seems pretty short. Well done lad.
>>
>>58213663
serious question for anyone feeling generous
I'm gonna be 31 when I get my associates in CIS (with a 4.0, from CC mind you) with only an Access Specialist cert. What should I do to become hire-able in either software development or db management?
>>
>>58218314
Put examples of your work on github. I cannot stress this enough. I got a job that requires a bacherlors degree simply because I put 2 half-assed projects on github. I have no degree, certifications, or prior technical work experience.
Utilize recruiting agencies to land your first job if you have difficulty getting that first company to give you a chance. If you can convince a recruiter you know what you're doing (much easier than convincing a hiring manager using only your resume) then they will hook you up with at least 1 job interview (maybe more depending on the specifics of how it went). Another great thing about recruiters is that they will tell you exactly why you didn't get the job and they can provide you tips on how to present/sell yourself. The downside of going this route is that contracts are volatile. You could lose your job at any moment much easier than a regular job. You also will not get the same benefits or days off as employees of the company you are contracted to work for. (this means holidays actually cost you money inherently since you won't be working or getting paid). The advantage of doing this is rapid work experience. Just make sure to be very professional. You can relax a bit once you have a real career later on.
>>
My decentralized TV system is about ready for a test broadcast (hopefully before new years). I have to tie up some loose ends, but it looks promising.
What should I play (only audio)?
Who here is interested in running a node or broadcasting out to the network?
>>
>>58218412
What were the projects? I got a fair amount of work on my GitHub, but I want to see what you call "half-assed" projects.
>>
File: 1469763556879.jpg (268KB, 777x578px) Image search: [Google]
1469763556879.jpg
268KB, 777x578px
>>58218273
I realized I forgot to include controls:
wasd to move
'g' to pickup items
'o' to open door
'i' for inventory
>>
>>58218461
I don't want to associate my true identity with my posts on 4chan, but I can describe them.

1. First OpenGL Project. C++ Rubik's Cube simulator with keyboard controls. No mouse support. No 3d Mesh. Just colored squares rendered for stickers. Memory inefficient. Slow when using large cube sizes (ie. 100x100x100 instead of 3x3x3)
2. C++ ImageMagick project to create collages out of images (intended to be used as a wallpaper generation tool). This entire project was crammed into a single .cpp file. Manually parsed the command line options like a newb. Kind of embarrasing actually. I've been meaning to rewrite it in Ruby and make it into a more elegant solution, but I've been working on a game engine lately.
>>
>>58218548
Nice, I am the guy posting about decentralized TV. I don't really want to tie projects with 4chan, but I think this is the best platform for getting the word out
>>
> That moment when it takes you and your team to figure out how to convert a negative number to a positive one

Maybe one of us should actually go to college
>>
>>58218717
*an hour, I don't know how I forgot that
>>
How can I average two ints in C?
>>
>>58218717

#define abs(x) (x < 0 ? -x : x)


>>58218732

#define avg(a,b) ((a<0)^(b<0) ? ((a+b)/2) : ((a/2)+(b/2)+(((a%2)+(b%2))/2)))
>>
>>58218773
Doesn't work for all inputs.
>>
>>58218788

Suggest an input that fails. I'm assuming we're doing integer averages, yes?
>>
>>58218796
Twelfty
>>
Can anyone help me out with this?
>>58218714

I might have posted it in a bad thread.
>>
>>58218849

error: twelfty undefined.
>>
>>58218858
It's ten more than eleventy.
>>
>>58218871

error: eleventy undefined

Please just write out the number using digits only.
>>
>>58218919
I tried writing it on the screen using my digits but nothing happened.
>>
>>58218919
>>
>>58218934
>>58218933
>>58218871
>>58218849
This is a pretty fucking lame joke.
>>
>>58213663
package main

import "fmt"

func main() {
ch := make(chan struct{}, 1)
go func() {
for i := 0; i < 40000; i++ {
fmt.Println("FAGGOTS!")
}
ch <- struct{}{}
}()
<-ch
}
>>
>>58218933

No, please post a string that matches the regular expression (0|1|2|3|4|5|6|7|8|9)+ that is the decimal representation of "eleventy" or "twelfty".
>>
-
Are you guys better at programming than your mates?

how do you cope with that feel?
>>
>>58217243
absolutely retarded
>>
>>58218956
>(0|1|2|3|4|5|6|7|8|9)+
d+
>>
>>58218956
e1eventy
twe1fty
>>
Learning D to make a roguelike with it. It's the best lang ever, imo
>>
File: 524343241.jpg (37KB, 400x267px) Image search: [Google]
524343241.jpg
37KB, 400x267px
>tfw want to do something that might actually be useful for society
>only sensible way is a website
>can't stand not having control over my shit
Should I just bite the bullet and dip into webdev? What's the way to go/tech that's closest to desktop dev/least annoying?
>>
Can someone explain why Mumble refuses to accept WinMove from Autohotkey?

It just completely ignores any WinMoves.
>>
>>58218978

There are characters in there that do not match the regex. Try again. Whole string has to match.
>>
>>58218956
116 119 101 108 102 105 116 121
>>
>>58219026
Apps are allowed to respond to events in non default ways
>>
>>58219053
How do I force it to move then?
>>
>>58219066
Maybe you can't without some code injection. Some apps are a pain to move.
>>
>>58219038

So in other words, eleventy is one hundred sixteen sextillion, one hundred nineteen quintillion, one hundred one quadrillion, one hundred eight trillion, one hundred two billion, one hundred five million, one hundred sixteen thousand, one hundred and twenty one, and twelfty is ten plus that number.

Hate to break this to you, but that won't fit into an int. It's not considered a "possible input", so I don't have to take it into consideration. In fact, it doesn't even fit into a double precision floating point number, or even a 64-bit unsigned integer. It'll only be valid input in arbitrary precision arithmetic.
>>
>>58219168
What's wrong with BigInteger
>>
File: Selection_007.png (92KB, 1357x477px) Image search: [Google]
Selection_007.png
92KB, 1357x477px
Are macro libraries considered a bad thing?
Kinda nice to not have to copy everything just to change the type name.
>>
>>58219249

Nothing wrong with it, but when you're only required to do averages on hardware integers, you don't have to take big integers into account.
>>
>>58219270
I can say the same thing for all data structures except 0 and 1.
>>
>>58218314
One more thing as a followup to >>58218412
Put a screenshot in your README.md for all applicable projects.
>>
#!/bin/bash

set -e

cd $HOME/.build/wine-staging
git pull
commit=$(patches/patchinstall.sh --upstream-commit)
wine --version
echo https://github.com/wine-mirror/wine/commit/$commit
echo WINE_COMMIT=$commit emerge -av wine


Script I just wrote to check the latest commit of Wine compatible with the staging patches, and make it easy to install that commit using portage.

The staging patches often don't work otherwise.
>>
>>58219260
Its fine.
I've seen some that actually generate the function definitions with macros, might be a better idea to do that?
>>
>>58217145
It makes it easier for others (and you!) to see blocks of code.
>>
>>58218273
Why not just use ncurses?
https://docs.python.org/2/howto/curses.html
>>
>>58219444
A goal of mine was to make sure it was cross-platform, and as far as I'm aware ncurses doesn't exist for Windows.

Also, was it fun?
>>
Should I learn Rust or Idris next?
>>
>>58218273
Traceback (most recent call last):
File "[dir removed]", line 443, in <module>
action = getch().decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
>>
>>58219668 this python3 on windows.

on debian i get
Traceback (most recent call last):
File "dum.py", line 443, in <module>
action = getch().decode()
AttributeError: 'str' object has no attribute 'decode'

but it's possible my python is out of date (i havent touched it in like a year).

one moment.
>>
Learning Golang through a bunch of ds/algo questions until I can think of a project.
>>
>>58219622
Rust was debunked a while back. Idris won't be useful for about 10 more years but you can learn it anyway.
>>
ded
>>
>>58219753
>>58219668
It's written for 3.5, probably doesn't work for python 2.x
>>
>>58220609
Oh, didn't see that part with you using version 3 already.

Then I don't know, apart from the "works on my machine". You could try checking lines 15-52, which is what I use to be able to get single character input without the return character on windows machines.
>>
>>58218273
Well done senpai.
>>
i noticed number 89 on the programming challenges picture. I didn't even roll. "program an HTML browser". How difficult is that one? what language should i use? I've only programmed in php and c#.
>>
Can anyone explain what Java stream does? It looks useful.
>>
>>58220409
>Rust was debunked a while back
How so?
>>
>>58220660
>"program an HTML browser". How difficult is that one?
Depends on your definition of "browser".

If it's just a web crawler that parses HTML, not too hard. If it's a complete implementation of the HTML5 spec complete with graphics, hahaha, you need an army of devs and a few years to /get started/.

>what language should i use? I've only programmed in php and c#.
If we're just doing a web crawler with parser, Perl.
>>
>>58220409
>Rust was debunked a while back.
How the fuck do you "debunk" a language?

>>58219260
>libraries
Those are just headers but yes, as long as you're not clobbering other definitions and don't do stupid shit behind the scenes or make up your own wacky syntax that clashes with the language, it's fine.

Shit like <stdint.h> are basically like that.
>>
>>58219012
I'd say yes. Look into Go or C# and TypeScript (if you need client-side). Everything else is a sanity drain.
>>
>>58218954
What's with the stupid struct?

Why not just use unit?
>>
Is Linux certification actually helpful in job qualifications?
>>
>>58213663
Wanted to learn c# so i started making a console application that scans websites for hidden admin pages.

It can currently pull out html so I was thinking of expanding on it to look for forms and try to attempt an sql injection.

But before that I'm making a port scan/ip scanner program that I can use to scan the internet for lulz
>>
>>58219622
I get the feeling that Rust is going to be a... I dunno what to call it, a "vaporware-filled" language? Every time something is wrong, the community goes, "it's coming in a later release", but that release never seems to come.
>>
In C++ does it matter if I do
// Comments here
#ifndef restofprogram
#define blahblah


vs

#ifndef restofprogram
#define blahblah
// Comments here
>>
>>58220928
Empty struct has sizeof 0 and can be used, if you have no payload to send and only use the channel to notify. Arguably sync.Cond would make more sense here.
>>
>>58220928
uints take space
>>
>>58220967
It really depends on the job. If you're applying to be a landscaper, I don't think it's going to help you.
>>
>>58221034
>>58221071
I find it hard to believe that even the golang devs would somehow make units take more space than an empty struct.
>>
>>58221030
I don't see why it would
>>
>>58221149
Yeah, I mean it compiles fine just wasn't sure if there was some convention about it.
>>
>>58221198
Just whatever you are consistent with or whatever the rest of the team is doing
>>
File: Capture.jpg (22KB, 420x180px) Image search: [Google]
Capture.jpg
22KB, 420x180px
>Hiro depriving me of my (you)'s
>>
>>58221106
What do you mean by "unit"?
>>
>>58221030
No, comments are ignored by the compiler anyway.
>>
File: 1464027954258.png (299KB, 480x480px) Image search: [Google]
1464027954258.png
299KB, 480x480px
>>58218273
I added an equipment system, a drop system, and some basic armor and weapons to test it with.

You know that dreadful feeling when you realize your code is not maintainable and everything is an ad hoc solution? That's my feeling right now.

I don't even know where the problem is, I just know that it is there, like some Cthulu-like horror.

Anyway, controls are:
wasd - movement
o - open door
g - pickup items
i - inventory
t - drop an item
b - access equipment and stats

http://pastebin.com/1Lr90dP6

Hopefully it's more """fun""" now.
>>
>>58221350
() AKA an empty tuple AKA a value of type 1. In this context the type 1 means the type containing exactly one value (the unit), whereas the type 0 would be void (no values of type void) and 2 would be bool (which has exactly 2 values). Does Go even have unit?
>>
>>58221697
if you think of tuples as product types, the type (A, B) is AxB... meaning that if A has M values and B has N values there are MxN values of the type AxB. The multiplicative unit/identity value is 1, which is where the term "unit" comes from.
>>
>>58221697
>Does Go even have unit?
I thought it did, which was why I brought it up.

Cursory google searches get me nothing though. Bunch of results about unit tests and the units package.
>>
Does anyone know how to change the default layout of a Code:Blocks project?

I want to select different DEFAULT libraries #included in the file.
In C, it's
#include <stdio.h>
#include <stdlib.h>

This is exactly what I want in C++, as well, and with no namespaces pre-defined.
But, I get:
#include <iostream>

using namespace std;


Anyone know how how to fix this?
>>
>>58222241
> using namespace std;
Disgusting.
>>
>>58222241
>>58222617
>C++
Disgusting.
>>
File: CHeader.png (36KB, 1231x501px) Image search: [Google]
CHeader.png
36KB, 1231x501px
>>58222617
Yeah, so do you know how to fix it..?

But, at this point idk if it even matters, though. I've already written an AHK Script that will fix it by typing chead in between x's.

>>58222634
Fuck off. I don't prefer to use C++ syntax for a lot of things. I write C++ code, for the most part, like C.

But I'm not gonna give up the ABILITY TO OOP, just because "HOLY FUCK! IT'S OOP!"
>>
>>58222705
OOP is fundamentally flawed, idiot.
>>
>>58222705
> so do you know how to fix it..?
Just write "std::" everywhere, all the cool kids do it.
>>
>>58222705
holy shit
>>
>>58222735
and using structs instead of classes, where all data is easily accessible without having to rely on functions, thus having no form of data-hiding, is certainly not flawed in anyway at all, fampai.

>>58222739
Who said I'll be using std:: all that much at all? printf(), puts(), gets(), and scanf() are good enough for most terminal IO, not to mention most C++ features embedded in a namespace aren't really necessary, not to say they're all pointless, by any stretch of the imagination, but C features will cover most program needs.

>>58222754
wew lad
>>
>>58222826
>using structs instead of classes, where all data is easily accessible without having to rely on functions, thus having no form of data-hiding, is certainly not flawed in anyway at all
Yes, that is actually true. Encapsulation is not a good thing most of the time.
>>
>>58222843
Explain why you say this.
>>
>>58222938

Hey, have a talk on this!

https://www.youtube.com/watch?v=QM1iUe6IofM
>>
C++ question:
Is there an actual advantage to using a singleton vs a namespace? Aside from data hiding I can't think of a single reason
>>
>>58222952
I'll watch that later; it's very long, and I'm reading over some stuff right now.

On the other hand, the use of Java in the thumbnail indicates that they're talking about Clucterfuck OOP. I don't use THAT kind of OOP; I use OOP sparingly and usually when it makes sense.

But, for clarification, so I don't waste my time:
This video will, in fact, explain why using encapsulation is bad in most cases? Not JUST OOPing the FUCK out of a program?
Because my question isn't "Explain why I shouldn't OOP like an Indian who's never learned anything but Java"; my question is "Why should I avoid data hiding?"
>>
>>58223041
>No true Scotsman argument
Idiot.
>>
>>58223040
Well you can use singleton in the contexts that require objects, like an argument to a function for example. Other than that, singleton is a stale meme and you should just use namespaces.
>>
>>58223055
"I uses classes left, right, and center" != "I use classes instead of structs most of the time"

This is not "No True Scotsman". I'm saying there is a middle-ground between being a never-OOP going-hardcore dumbass and an always-OOP hardcore-dumbass.
>>
>>58223041
All OOP is a clusterfuck
>>
File: 1472657215005.png (596KB, 1420x1067px) Image search: [Google]
1472657215005.png
596KB, 1420x1067px
>>58223095
>classes instead of structs is OOP
>>
>>58223041

The main point the video makes is that encapsulation and data hiding make OOP bad, particularly when used as they are supposed to be used. The author argues that people often end up breaking encapsulation in one place or another despite jumping through hoops to try and make it work in the first place. There's some other points to it as well, but I think the central argument is that encapsulation is fucking useless.
>>
>>58223150
Alright, I'll check it out.

>>58223105
Well, I do use at least SOME level of Polymorphism as well. That comment was worded very dumb, tbqh.

But either way, it's makes logical sense to create objects that have similar functions, such as "graphicalObject" branching into 3 things: "itemObject", "environmentObject", and "characterObject" (which in turn would branch into "npcObject" and "playerObject") if you were, say, making a game
>>
>>58223265
OOP polymorphism is vastly inferior
>>
>>58223279
Ok, this I would actually like to know. They don't actually discuss any other type of polymorphism in classes, and I haven't really seen anything about it in the books I've read.
What other way can you create "subcategories of things" without subclasses?

Any links would be helpful. I turn up a bunch of mostly unhelpful stuff when searching for it.
>>
Any tutorials for setting up a website that will allow a user to make selections on multiple different items and then save those selections.

It's for an employee rating database.

I was think something like django, but if there's anything else, I'll happily use it. Never really done web stuff before.
>>
>>58223382
You mean like a multi-select of checkboxes or something? PHP can automatically process that. Then, you can store it using some type of object notation. Could use JSON or a custom ON and explode the array on the delimiter.
>>
>>58223373
Haskell type classes are like interfaces, you can also use existential quantification


Existential quantification:
data S = forall a. S a (a -> String)


forall a is like parametric polymorphism, i.e.
template <typename A>

data S is like a definition like struct S or union S
the bit on the right are the constructors, so this is like

struct S {
template <typename A>
S(a, string(*)(a));

void* data; // implicit/implementation
}


Notice how the A template doesn't appear on the struct itself, i.e. there's only one type, but there are many constructors.
>>
>>58223421
Basically, each year they will set up marking criteria, and then be rated against that criteria. It might be 2 things under a performing well and one thing from a performing badly. And then those columns get averaged (eg, one thing in column 2, one in column 4, one in column 6, average score 4)

This will need to be accessible by a number of people for different roles on each employee.

I still need tutorials on setting it up.
>>
>>58223373
>>58223436
So you don't know what type a is (what "sub-type" if you're using it for that sort of thing), but you do know that the function you're given (a -> String) can accept it as an argument.
So if you instead gave this some names:

data Showable = forall a. Showable { data :: a, displayFn :: a -> String }


you know how to display it, because the types match up

display :: Showable -> String
display Showable{data=x, displayFn=f} = f x


this is like

struct Showable {
template <typename A>
Showable(a data, std::string(*displayFn)(a)); // store these args in the void pointer

std::string display() {
return displayFn(data);
// recover these from the void pointer
}


void* __implementation; // store all constructor args in this
}
>>
>>58223490
And this corresponds almost directly to the way C++ implements OOP - you're storing a pointer to the function along with your data. (in C++ it'd be a pointer to a vtable, a collection of functions)

You can do the same thing in C, but without type checking

typedef struct {
void* data;
char(*displayFn)(void*);
} Showable;
>>
>>58223436
>>58223490
>>58223507
Hmmm

I'll have to look into that.

But that Haskell part means nothing to me; I don't know Haskell.

>>58223464
https://www.formget.com/php-checkbox/
You can use this to get checkbox data, or you can choose to use radio dots.
Just have the thing take the values and perform the necessary functions on them.
For what you said, it might look something like:
if(isset($_POST['col1val']) && [same for the others]){
$average = ($_POST['col1val'] + $_POST['col2val'] + [other necessary columns, possibly multiplying by weights]) / [the number of columns];
}


Something of that nature should work.
>>
>>58223622
data T = A Int | B String Char

this is a data declaration, you can think of it as meaning

>a T is either an A (consisting of an Int) or a B (consisting of a string and a char)
x,y :: T 
-- x and y both have type T
x = A 3
y = B "asdf" 'X'


data T a = A a | B String a

the "a" is a type variable, this is like
template <typename A>

e.g.
x :: T Int
x = A 3
y :: T Bool
y = B "asdf" True


the important part is that in the following:
data S = forall a. S a (a -> String)

the "forall" is on the right hand side.
i.e. in C++ that the
template <typename A>
isn't on the struct S, it's on the constructors
because it's on the constructors, whatever A is, the struct S will be the same type
>>
>>58223704
Hmmm, ok
>>
New thread:
>>58213663
New thread:
>>58213663
New thread:
>>58213663
New thread:
>>58213663
>>
>>58224131
You quoted the OP. Not a new thread
>>
>>58224154
58224196
>>
>>58224200

faggit >>58224196
>>
>>58224226
>created before the bump limit
Delete this
>>
>>58216443
>great programmers
>>
>>58222705
>I write C++ code, for the most part, like C.
I understand where you're coming from and why you might think that's okay, but coming from someone who's not a fan of C++, if you're going to write C++, you need to write it as idiomatic C++, not C-style C++.

If you're not going to use C++ features, stick to pure C.
Otherwise, write C++ code properly.

You are only hurting yourself when you do this.
>>
>>58226141
Malloc in C++ lol
>>
File: firefox_2016-12-29_16-33-48.png (186KB, 578x376px) Image search: [Google]
firefox_2016-12-29_16-33-48.png
186KB, 578x376px
I want to do some stuff with the Youtube API, I tried prototyping this with nodejs and the provided API libraries. Needs a web interface, oauth login, probably a small database.

Python or Javascript?
Thread posts: 309
Thread images: 23


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.