[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: 364
Thread images: 28

File: GzWHnnI.jpg (90KB, 600x400px) Image search: [Google]
GzWHnnI.jpg
90KB, 600x400px
old thread: >>57656992

What are you working on, /g/?
>>
thanks for not using a fag image
>>
File: 1463214119312.png (300KB, 469x540px) Image search: [Google]
1463214119312.png
300KB, 469x540px
>C# C++ java python
>>
>>57660748
Please post a (non-fag) anime image next time.
>>
template<class K, class D>
D& BTItr<K,D>::operator*(){
return node->data;
}

why invalid ihitialization from non const ref of type "double&" from an rvalue of type "double"?

returning a reference to a member var, shit makes no sense. WOrks if I add "return (D&)(node->data)
>>
>>57660748
>>>/fb/
>>
>you will never get to sit in bjarne's lap while he lectures you on C++
why even live
>>
File: 1467621018816.png (271KB, 393x383px) Image search: [Google]
1467621018816.png
271KB, 393x383px
im crashing this thread... with no survivors!
>>
to what limit should i unit test my code?
say im writing a poker game and want to test the hand types (full house, royal flush, etc), should i automatically generate code to permute all (or tons) possible hands for full house to test it's correctness?
>>
Employed Haskell programmer reporting in
>>
>>57660785
Unit testing is for fools.
Real programmers formally prove their programs to be correct.
>>
>>57660794
this
>>
>>57660794
but i dont want to formally prove my program everytime i refactor or add some trivial lines.
>>
>>57660786
Was getting employed part of your plan?
>>
>>57660786
facebook uses haskell to detect spam/malicious links in messenger
>>
>>57660804
you're a big guy
>>
>>57660804
Hoare logic is modular, so you can simply add at least one more proposition to the proof.

>>57660786
Can you comment on the alleged meme status of category theory?
>>
>What are you working on, /g/?

I am procrastinating on an assignment that uses Artificial Neural Networks with Back Propagation. I am also procrastinating on writing a fucking CV and Statement of Intent.

Should probably get to all of this after Turkey Day.
>>
How do I avoid using the long double literal suffix if I want to use long double in c++?
>>
>>57660748
if (op.image.isXKCD == False) {
reply ("Please post XKCD next time!");
}
>>
>>57660814
This is a good idea.
>>
>>57660885
agreed. it also has the micro-optimization benefit that you only shuffle a step when required.
>>
>>57660766
give us more context, like what is node, data etc etc
>>
>>57660785
unit testing is more for games. for any other kind of data modelling you're going to want be rigorous and create relationships from the data to model that rigor.

science isnt about truth in any conventional sense. its about clarity. "clearly its true, scientifically proven so." we didnt make these systems to fight religion, we made them to hold off bad marketing and bad practice in general. if you can read the matter of the science, usually in the form of math, then you can tell when someone has given you a bad figure and thus see the truth in it. otherwise, people in the right positions can make any claim and you have to pay any amount for whatever reason regardless of any "ill conceived" prejudice you may have against the market or its peoples.

still science is rooted in the senses, individual senses, and its up the individual to abstract the data in a way thats feasibly direct enough to be apportioned via service or consul.
>>
How do I read a Python source file, instead of executing it on click?
>>
>>57660923
right click -> open with?
>>
>>57660965
or right click -> edit
>>
>>57660785
Sure, why not.
There are only about 2.5M hands, so you can check every single one in less then a second (assuming your code isn't shit)
>>
>>57660974
well, I'm writing it in assembly so it can't be that shitty.
>>
>>57661009
if you're serious you should benchmark it against compiler-optimized C/C++
>>
>>57660843
>Hoare logic is modular, so you can simply add at least one more proposition to the proof.
Almost nobody uses whore logic in practice.
>>
>>57661126
>whore logic
Kek
>>
If Haskell is the best language,
why do Computer Science PhDs exist who choose Java?
>>
>>57661368
They fell for the silly memes.
>>
https://www.youtube.com/watch?v=676FMfkYxOk
>>
Has anyone here done
1. The Cryptopals Crypto Challenge - http://cryptopals.com/
2. The Eudyptula Challenge - http://eudyptula-challenge.org/
>>
Zed Shaw is silly

https://learnpythonthehardway.org/book/nopython3.html

>Currently you cannot run Python 2 inside the Python 3 virtual machine. Since I cannot, that means Python 3 is not Turing Complete and should not be used by anyone.
>>
>>57661715
>silly
This whole post is absolutely retarded.
>>
How would I format the values of a vector in c++? So when I input some values into it it's "1.0f" instead of "1" automagically?
>>
Is there a better alternative to Project Euler? I love it and don't really want to switch but I wonder if there is a better choice
>>
>>57661779
vector of a different type of number
>>
File: wf5.png (81KB, 1240x1060px) Image search: [Google]
wf5.png
81KB, 1240x1060px
More progress on my Forth compiler.
CREATE (variables and data) working.
Now the tricky part, implement DOES> (which is one of the things which makes Forth, Forth). It's enough of a mind bender just using it in the language itself. Implementing it is gonna require generating code which compiles code that compiles code in the current definition, it's like three levels of nesting to keep track of.
I find myself needing some better notation, I though x_FOO and c_FOO was enough for execution semantics and compilation semantics, but now there's also execution semantics of resulting compilee defintions, almost getting lost in my own code.
>>
coding isn't the same as programming
>>
>>57661820

Programming is a proper subset of coding
Scripting is a proper subset of programming
>>
>>57661804
>Is there a better alternative to Project Euler?
In what aspect? What is it you want to learn?
>>
Passpoint/Hotspot 2.0 profile generation for Android devices
>>
>>57661715
>note
>Yes, that is kind of funny way of saying that there's no reason why Python 2 and Python 3 can't coexist other than the Python project's incompetence and arrogance. Obviously it's theoretically possible to run Python 2 in Python 3, but until they do it then they have decided to say that Python 3 cannot run one other Turing complete language so logically Python 3 is not Turing complete. I should also mention that as stupid as that sounds, actual Python project developers have told me this, so it's their position that their own language is not Turing complete.
You're giving him the attention he so desperately wanted by using that clickbait quote that you just linked for clickbait.
>>
>claims to know C++
>can't solve this simple problem

 
//assign goo to bar then call bar
class Foo
{
public:

void goo(){};
static void (Foo::*bar)();
};
>>
>>57661834
what's the difference between scripting and programming?
>>
>>57661715
>>57661880
p.s. This is an entirely misguided issue because once you've started concerning yourself with these kinds of issues you've removed yourself from productive programming and are basically just getting some job security from obfuscating the development process.

Which you really don't need if you can manage to do this in the first place.
>>
>>57661866
Basically I've heard about sites that make future employment easier, like a ranking of coders. Euler's learning value is incredible indeed. What I meant by writing 'a better alternative' is 'an alternative with broader perspective'.
>>
>>57661881
Foo::bar = &Foo::goo;
Foo f;
(f.*Foo::bar)();

now fuck off
>>
>>57661881
>claims to know C++
Alas I have made this mistake, nobody actually knows C++. Not even the committee. It's simply the nature of a large stupid language.

This just tests your ability to work with what's essentially C's function pointers though.
>>57661900
>
(f.*Foo::bar)();

Can you not just do
*(Foo::bar());

As it's a static variable.
>>
>>57661900
>(f.*Foo::bar)();
Why can't you just do (f.bar)() ?
>>
>>57661900
>>57661923
Won't work.
>>
>>57661923
It's a static variable but it points to a function that needs an object. That solution won't compile anyway.
>>
tits and/or age
>>
>>57661982
>tits
Too big but rapidly shrinking.
>age
23
>>
>>57661538
Anyone?
>>
>>57661981
Oh yeah you're right. Obviously an implicit this pointer. Man I love OOP. It's just so clear and easy to read.
>>
File: attention_grabber.jpg (242KB, 2000x1347px) Image search: [Google]
attention_grabber.jpg
242KB, 2000x1347px
From last night:
>me: How do i interpret a byte sequence as any arbitrary data type, where the data type is given by the user during runtime?
>anon: Call a function?
>me: So i need write function for every datype that exists?
>anon: Generate it compile-time using templates or a similar system.
>me: That still means i have to manually call the template once for eath data dype.
>anon: Generate that too with metaprogramming. Generate the entire function with the multiple codepaths.
And then i fell asleep.
So to pick that up, how do i do this? How do i generate everything with metaprogramming?
Working in C++, btw.
>>
>>57661987
I'm into eudyptula challenge, but its pace is too slow. I'm awaiting two weeks for the results of challenge 16.
>>
>>57662000
>arbitrary data type
What do you mean by arbitrary? You obviously can't support any possible data type, and that would require infinite code.
What data types do you actually want to support?
What are you even doing with that data?
>>
>>57661715

Zed Shaw is a close-to-borderline idiot.

Bascially all his writing is about "stop liking what I don't like".
>>
>>57662021
I just sent them an email saying I want to join. What should I expect from the challenge?
>>
File: scrotum.png (74KB, 626x514px) Image search: [Google]
scrotum.png
74KB, 626x514px
what the fuck with that huge ass binary file?
>>
>>57661811
what?
>>
>>57662039
the more challenging part is configure your email client to behave (send as plain text and don't mess with the attachments). For the challenge in itself you can do every chapter in matter of minutes or hours if there is a long compilation.
>>
I just learned about binary trees, and there was an exercise to mirror it. I've always heard about that problem as a super hard interview question. But irt's easy as shit. 8 lines in c.
Are graduates really this stupid?
>>
>>57661834
>Programming is a proper subset of coding
>proper subset of coding
>proper
>coding
kek

How can tripfags be this retarded?
>>
>>57662061
I hope I have done that part correctly.
Here's what is says in the email header of what I sent them
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
>>
>>57662074
yes they are
>>
>>57662074
>I've always heard about that problem as a super hard interview question.
Seriously?
>>
>>57662000
>How do i interpret a byte sequence as any arbitrary data type, where the data type is given by the user during runtime?
Sounds like you actually want to just handle the byte sequence rather than a data type, as this is what they give you. If they're just supposed to give you a name like "vec2" and you call the function for vec2 then yes templates do seem like easiest solution within C++. Unless you use your own metaprogramming.

If you're aiming to have the user input something like:
struct Foo{
int a,b,c;
}

And then have the code respect the types and fields of that struct. That sounds very difficult. You'd have to write a basic C/C++ interpreter/compiler, allocate some executable memory and compile the code into that memory to then run it. So you're basically just doing templates at run time. I'm not sure what the goal would be here, how would you know the implementation without knowing the data at all? Do you presume certain things about the names of the types?
>me: That still means i have to manually call the template once for eath data dype.
That's not a big deal. Write your own pre-processor which extracts all the types in the program and inserts them into a header which you then include where appropriate. It's probably easier to do that way than with template metaprogramming.

If C++ had decent reflection and or introspection it would be much easier.
>>
>>57661881
>>57661900
>>57661954
Yeah I don't know how to do this.
Is this a case where C++ simply doesn't work or is there some trick?
>>
>>57662022
Well, primarily every primitive data type.

But in the longer run it would be nice to let the user extend that to any data type the user desire, using scripting. But that would require me to learn how to embed scripting support in the my program, which i don't know how to do either.

I'm thinking about how i would write a hexeditor that supports data type reinterpretation. Kind of a program to help analyse binary files.

Kind of like
>i want these bytes to be interpreted as unsigned int
>these bytes as short
>these bytes as flot
>these bytes as chars
>these bytes as long long
>these bytes as float64
>these bytes as a big endian float
>those bytes over there as MyStruct, whatever that may mean.
>>
>>57662074
>I've always heard about that problem as a super hard interview question.
It's more like a basic, intro level question. If you can't answer it, there is no need to talk further when we talk about real positions.

>Are graduates really this stupid?
They are, plus there are a bunch of so called "software engineers", "coders", "app developers", etc. who are actually really shit autodidacts, far away from the skills of a real autodidact and/or someone who attended university. They think they're some kind of actual programmers, developers on the same level as people (regardless whether we talk about an autodidact and/or university educated guy) who are a lot more serious (and talented) about their shit and aren't afraid of babby-tier math. Most binary tree stuff is quite trivial.

So when these people get a basic question to test whether they can actually think in terms of basic computer theory than they flip and start spamming twitter/tumbler/blogs/etc. with their shit.

I don't want to generalize here, but most guys with a "cool" hipster sounding job are usually shit. They're like at a technician level (or even lower) compared to an actual university graduate (or to people with an equivalent knowledge).

Real good autodidacts are hard as fuck and most of them gets a degree sooner or later even if they only get it for the paper. These are the kind of people who can easily beat a university grad in skills and knowledge.
>>
>>57662041
ghc does not optimise by default, use '-O2' and then strip it with 'strip'.
>>
Woooo, calling native code from a shell!

rubyist@Overmind:~/Desktop$ powershell
PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS /home/rubyist/Desktop> $src = @"
>> using System;
>> using System.Runtime.InteropServices;
>>
>> public static class NativeMethods
>> {
>> [DllImport("./foo.so")]
>> public static extern Int32 add_numbers(Int32 a, Int32 b);
>> }
>> "@
PS /home/rubyist/Desktop> add-type -TypeDefinition $src
PS /home/rubyist/Desktop> [NativeMethods]::add_numbers(1,2)
3
PS /home/rubyist/Desktop> ls
foo.c foo.o foo.so
PS /home/rubyist/Desktop> cat foo.c
int add_numbers(int x, int y)
{
return x + y;
}
>>
>>57662134
>so called "software engineers", "coders", "app developers", etc.
That's a strange way to spell 'Pajeets'
>>
>>57662086
>Write your own pre-processor which extracts all the types in the program
I don't think i know how to do this either.
>>
>>57662149
I wrote it like that because there are legit people holding those titles, although it gets more rare these days.
>>
>>57661884

Scripting is a special case of programming wherein a scripting language is used.

A scripting language is defined as a programming language wherein the executable file and the source code file are one and the same.

>>57662075

Why yes, it is a proper subset. All programming is coding, therefore programming is a subset of coding. Not all coding is programming (markup languages are "code", but not traditional programming languages), therefore the sets are not equivalent. Since programming is a subset of coding and is not the same set as coding, it is a proper subset.
>>
>>57662194
>the executable file and the source code file are one and the same.
what?
>>
>>57662134
>They are, plus there are a bunch of so called "software engineers",
If I translate the name of my bsc word for word, it be software engineer in english
>>
>>57662194
>executable file and the source code file are one and the same.
Nit-picking, but can't you write a compiler and an interpreter for every language.
Also, what would you say about python? It generates .pyc files but you can execute it directly in the interpreter too.
>>
>>57662194
>the executable file and the source code file are one and the same.
That's just a convoluted way of saying interpreted language
>>
>>57662207

Meaning you do not compile it ahead of time to a bytecode or native code format.
>>
>>57662152
Look up a recursive decent parser and parse a tokenized version of the code.
Figure out how you recognize what's a defined type (words like class, struct and union often come just before the type).
Process the tokens and extract the types into a set of preference (no duplicates).
When you have that you just fprintf() your template calls it to a .h file.
Include the file where you want to call all the different versions. You can put in a volatile static variable and branch around all the calls if you so choose to not have to actually call them as initialization.

It's not that much when you know what to do but it's probably a bit confusing if you're new to non-template metaprogramming.

But it's not uncommon to have tools that process your source to construct other code or files. So it's worth learning.
>>
>>57662194
So you don't agree that there are no aspects to programming that do not necessarily involve writing code?
>>
>>57662219

>Nit-picking, but can't you write a compiler and an interpreter for every language.
Yes, and if you use an interpreter, you are scripting. If you use a compiler, you are not.

>>57662221

Just wanted to be more explicit.
>>
>>57662223
that's retarded. first, a source code is not a executable, it's either interpreted or compiled. second, with your definition, every programming language is also a scripting programming language.
>>
>>57662227
Oh, i see.
>>
>>57662194
>A scripting language is defined as a programming language wherein the executable file and the source code file are one and the same.
No it's about how the programming language is used/intended to be used.
>>
>>57661368
haskell is not the best language

java is the best language
>>
>>57662244

#!/usr/bin/env bash

echo "Hello World"


is an executable, and the operating system will see it as such.

Also, every programming language has the capacity to be a scripting language, but unless it is being used as such, it is not scripting.
>>
>>57662268
>t. Pajeet
>>
File: Recursive descent parser.png (12KB, 511x94px) Image search: [Google]
Recursive descent parser.png
12KB, 511x94px
It's like a parody. That name.
But it's a good explanation of a recursive decent parser.
>>
>>57662108
There is a trick.
>>
>>57662194
Only the use of code as a verb triggers me.
>Writing code can either mean writing programs or other shit.
Your logic is sound though.


>>57662210
There is a reason I put it inside "". I was naming jobs and the titles some people call themselves (even without qualifications). My point was to point out the lot of bullshit going on with jobs and how despite the title the work is far away from what you would except, people are too in terms of skill.


Translating can be a bit tricky, we have (had) the same kind of naming shit around here yet most of the courses are what a computer science degree would encompass rather than an SE degree. Course material matters more than the name of the degree.


As far as I know lot of SE degrees in the US are basically stripped down CS degrees with a focus on enterprise software development, etc. instead of theoretical foundations (or at least on a lot weaker level than someone with a CS degree).

Btw, we had Software Designer Informatician (one to one translation) as the name of our CS degree here. Back in the day it was called Software Designer Mathematician. For the newer term a fitting translation would be Software Engineer, yet the course material is ~80% theoretical CS stuff.
>>
>>57662194
>A scripting language is defined as a programming language wherein the executable file and the source code file are one and the same.
Wrong.
>>
File: kek.png (49KB, 1118x198px) Image search: [Google]
kek.png
49KB, 1118x198px
>>57662277
https://www.youtube.com/watch?v=pDHfgknlDrY
>>
>>57662281
Man I thought I was done but now it's just complaining about how the term doesn't evaluate to a function taking # arguments. Where # is whatever I put there. Such nonsense.
#include <stdio.h>
//assign goo to bar then call bar
class Foo
{
public:

void goo(){printf("It werks!");};
static void (Foo::*bar)();
void callBar(){(Foo::bar)();}
};

int main(){
Foo f;
f.bar=&(Foo::goo);
f.callBar();
return 0;
}
>>
>>57662305
>Software Designer Informatician (one to one translation) as the name of our CS degree here. Back in the day it was called Software Designer Mathematician.
Are you hungarian?

>SE degrees in the US are basically stripped down CS degrees with a focus on enterprise software development
Yeah, that,s shitty
>>
>>57662400
Yes, are you? Greetings, haver.
>>
File: wf6.png (80KB, 1355x1046px) Image search: [Google]
wf6.png
80KB, 1355x1046px
>>57661817
CREATE DOES> working!
Was actually easier than I though since saved return address after a call is exactly what I needed to fixup the jump to the DOES> part.
And since you pop off the saved rsp, you then return and skip the DOES> part for the defining word.
It's when you wanna do things like this that assembly actually makes things easier for you.

So you can now create arbitrary compiling words, flow control words and defining words.
Now comes the extreme drudge work: Writing an x64 assembler/disassembler.
Maybe I'll skip the DIY approach for this and use some library, because fuck x86 opcode encodings.
>>
>>57662445
Nice!
>>
>>57662445
Are you rolling your own lexer and parser or using flex/bison etc?
>>
File: 1466014189324.jpg (181KB, 1024x967px) Image search: [Google]
1466014189324.jpg
181KB, 1024x967px
>>57660748
Guys. How do I become an amazing programmer like Kloss?
>>
>>57662576
kek
>>
>>57662576
Is that a laptop made for midgets or does she have gigantic man hands?
>>
>>57662576
Get a large instagram following.
Post code.
>>57662594
It's small.
>>
>>57662550
Completely overkill to the point of insanity for parsing Forth.
The parser is 36 instructions for extracting space delimited words, and another 32 instructions for converting a string to a number and that's all you need
So about one screen worth of assembly instructions for the entire lexer/parser.
>>
>>57662576
To be fair, using the command line can be a bit intimidating at first.
>>
>>57662618
Sounds good, are you gonna make it open source? Would love to take a look at it.
Also, when you finish this, you should rewrite your compiler in Forth.
>>
>>57662653
Not him, but why? Why when it's finished, there are already forth interpreters.
>>
>>57662669
I thought Forth was an entirely new programming language designed by him. I should go kill myself now.
>>
>>57662653
>Sounds good, are you gonna make it open source?
Yes, will be published soon, just need some cleaning up (lots of hardcoded test cases and stuff atm).
>Also, when you finish this, you should rewrite your compiler in Forth.
That's definitely the plan.
Technically now with create does> + a for loop I can bootstrap everything by just copying chunks of machine code for the primitives (like if, else, call word), but it would essentially be a hexdump of machine code as strings being the 'Forth source'.
>>
File: ruby on rails.jpg (59KB, 720x720px) Image search: [Google]
ruby on rails.jpg
59KB, 720x720px
Can you guess who the best programmers is among these girls?
>>
>>57662689
Don't worry, I didn't know before as well.
>>
>>57662719
The one who hasn't been able to get by in life on her looks alone?
>>
>>57661715
>python3 is not Turing complete because you can't run python2 bytecode in the 3 VM
Dear God, what?
>>
>>57662749
>mfw C preprocessor is Turing complete
>mfw C preprocessor is literally better than python3
>>
>>57662719
The guy?
>>
>>57662762
Unless you're talking about m4, I wouldn't call it turing complete, look at the shit I had to go through to get over some limitations https://github.com/EvilPudding/RFI
>>
>>57660748

>both are turning at the same speed
>>
>>57662762
But python3 IS Turing complete...
>>
>>57662689
It's a bit obscure, kinda low level but at the same time extremely high abstraction ceiling.
You manually fiddle with a stack to pass parameters around (no named variables, everything implicit), no type checking, and read/write to raw memory addresses, but because of the compiler is exposed to you (and is very easy to extend and modify), you can create code looking like essentially English sentences.

CREATE DOES> in particular is one of the coolest features of the language, it kicks the shit out of any OO language when it comes to building up data structures to manipulate.
>>
>>57662782
>look at the shit i had to go through
Irrelevant to the definition of Turing completeness.
>>
>>57662838
Sounds pretty great.
>>57662863
I know, though if I ask you to give me binary search in good old preprocessor would you?
>>
>>57661817
>>57662445
This is awesome. I wish I had skills to do something like this. But I'm not smart enough.

Hell, I can't really even handle Forth. A while ago I was reading about it, then stumbled upon Jonesforth. Reading its source (fortunately I know just enough bits and pieces of assembly) and jonesforth.f file was mind-blowing. I realized the language itself was implemented in Forth. My mind expanded in ways I can't deal with, and I ran. C and C++ are restrictive enough for me, but Forth is too much power.

I wish you good luck.
>>
>>57662838
>you can create code looking like essentially English sentences.
yuk, I hate when langugaes try to look like english.
>>
>>57662576
Is this supposed to look like a spur-of-the-moment thing? Who is taking the photo here if both her hands are on the keyboard?
>>
>>57662815
I know, it was just a joke, why you heff to be mad?

>>57662782
No, I wasn't talking about m4. I saw a project some time ago where a guy had literally built a Turing machine simulator using only the C preprocessor. -- http://www.ioccc.org/2001/herrmann1.hint
>>
>>57662782
>>57663137
So it turns out it isn't actually Turing complete. Taken from that website

>Well, the answer is simply that the
preprocessor is _not_ Turing complete, at least not if the program
is preprocessed only once.

>Well, this entry _is_ a Turing machine implemented in the
preprocessor; so of course, it has to be preprocessed several
times.

Anyway, it's pretty cool.
>>
>>57662950
Just meant to say you can essentially make the syntax look however you want.
>>
>>57663384
I get you. Forth does sound pretty cool based on what I've heard of it.
>>
>>57663384
Can you post what fizzbuzz would look like in Forth?
>>
>>57663673
: say
create
,
does>
tuck @ mod 0=
if
>name count type 1 or
else
drop
then
;

3 say fizz
5 say buzz

: fizzbuzz
do
cr
false
i fizz
i buzz
0= if i . then
loop
;

One way to do it, exploit the fact that the dictionary exist and reuse the name of the function as the string to print.
>>
>>57663784
Dictionary as in like Python dictionaries (hashmaps)? In such a low level language?
>>
File: purepwnage.png (290KB, 808x514px) Image search: [Google]
purepwnage.png
290KB, 808x514px
>>57661715
Did you read Eevee's rebuttal?
eev (dot) ee/blog/2016/11/23/a-rebuttal-for-python-3/
Pretty brutal
>>
>>57663811
The dumbest thing about python 3 as far as i can see is calling it "python 3". It's not backwards compatible, so it's basically a new langugae.
>>
>>57663801
every language with a runtime has a symbol table for lookups
many use hashing for it
>>
>>57663834
What should they have called it?
>>
>>57663849
I know, so you're telling me that Forth is so low level that you can use the compiler symbol tables as dictionaries? That's pretty cool.
>>
>>57663880
"better python" "python++" or some shit. Or some other snake name completely.

Though even C++ was a superset of C when it started...
>>
>>57663811
>But can you run Java and C# at the same time? (I’m sure someone has done this, but it’s certainly much less popular than something like Jython or IronPython.)

Isn't IKVM.NET pretty popular?
>>
def calcPenniesLeft(penniesLeft, penniesRemoved):
penniesLeft = penniesLeft - int(penniesRemoved)
penniesRemoved = 0
return


How would I write this so that penniesLeft is changed by the method? As I understand it strings and integers are immutable and therefore cannot be changed in a method they are passed to.

In C++ I just pass by referenced penniesLeft.
>>
>>57663964
The only way to pass by reference is using lists.
>>> x=[0]
>>> def foo(n):
n[0]=1
>>> foo(x)
>>> x
[1]
>>
>>57663964
pass a dict :^)
>>
>>57663964
Make them global, or properties of an object.
>>
>>57663964
put the values in an object and just pass the object.

integers are mutable, but they are value types and are copied on reference.
>>
>>57660748
the one that I'm not looking at is the one that spins
>>
>>57660841
for you
>>
>>57663894
"snek"
>>
Using an older C++ .lib file. When I try to use it in my project, I guess it has a dependency for a super old, no longer supported .lib file, 'libci.lib'. Microsoft says it's discontinued and shouldn't be used. How do I still use the lib I want?
>>
>>57660918
feels like i just read a terry davis blogpost
>>
>>57664109
Find the lib and use it anyway?
>>
>>57662281
So what's the trick anon?
>>
>>57664163
I tried tracking down libci.lib, but it seems it was a Microsoft C Standard lib that was included in Microsoft Visual Studio 6, or something similar. So without installing that, I'm not sure I can even get it. I'd rather not have to do all that for a lib file.
>>
>>57662000
just use boost::any.
>>
>>57664205
IIRC I've had problems linking with old.lib files on MSVC.
So I'm not sure it'd even work.
>>
>>57664214
>just use
>boost *ominous echo*
Please anon, that library must not be named.
>>
File: wut.jpg (53KB, 646x570px) Image search: [Google]
wut.jpg
53KB, 646x570px
>>57664214

It was fun assigning autistic variable names at first, but now I realize there's no going back.
>>
>>57664227
I ended up adding that lib file to the ignored lib files. I then had to track down the newer lib/header files that had the functions d3dx8.lib was trying to use. Was a pretty big pain in the ass, but figured it out.
>>
i don't get how ruby is slow if it's written in c
>>
>>57660786
What does your job entail?
>>
>>57664297
Ruby isn't written in C, Ruby is written in Ruby.
>>
>>57660786
>Employed Haskell programmer reporting in
Are you employed as a Haskell programmer?
Be honest..
>>
>>57664297
It's interpreted, not JITed.
>>
>>57664343
Yes and I get to wear stockings at work
>>
>>57660918
>unit testing is for games
Unit testing is absolutely NOT for games. Because testing the specific interactions is more often than not impossible.
Ignoring very specific categories of games like card games or certain turn based games.
>>
File: 1435428133070.jpg (68KB, 563x491px) Image search: [Google]
1435428133070.jpg
68KB, 563x491px
>tfw still can't average two ints in C
Who here /knowsthisfeel/
>>
>>57664419
I can only average one int, if that makes you feel better
>>
File: images-89.jpg (12KB, 332x444px) Image search: [Google]
images-89.jpg
12KB, 332x444px
>>57662132
>data type reinterpretation
You mean serialization/deserialization?
>>
>>57664419
>type convert to float
>divide by 2
>sum
>>
>>57664419
int 
avg(int a, int b) {
int i;
int lo = (a < b) ? a : b;
int hi = (a < b) ? b : a;
for (i = lo; i <= hi; i++) {
if (((hi-i)-(i-lo)) <= 1) {
return i;
}
}
}
>>
>>57664419
think about it

you can't just do (a + b) / 2 because overflow

so do a / 2 + b / 2

now where does that get you, you lose the remainders, so add them back in:
a / 2 + b / 2 + (a % 2) + (b % 2)

what do you have now, it's almost right but not when a and b have different signs. but you're in luck because when a and b have different signs you can add them without overflow:
return (a < 0) != (b < 0) ? (a + b) / 2 : a / 2 + b / 2 + (a % 2) + (b % 2);


or something like that i don't remember exactly if this is the correct solution
>>
>>57664419
This meme still hasn't died?
>>
>>57664472
This can overflow
int 
avg(int a, int b) {
int i;
int lo = (a < b) ? a : b;
int hi = (a < b) ? b : a;
for (i = lo; i <= hi; i++) {
if ((hi-i) <= 1 + (i-lo)) {
return i;
}
}
}
>>
I remember where an argument about average of numbers in computers were about float and correct statistical truncation.
I didn't know the wisdom of the IEEE and I learned something.
Now we sadly only deal in trolls.
>>
>>57664472
>>57664508

> average of two integers is an integer
> average of 3 and 4 is an integer

Do you even math ?
>>
>>57664521
this is bait
>>
>>57664521
Define an integer.
>>
>>57664535

Define 'an'
>>
>>57664535
an element of Z (can't do the bold Z, but i am talking about the mathematical set of all integers)
>>
SQL master race
>>
>>57664580
Define \mathbf{Z} then. You can't just say that it's the set of integers, that would be a circular definition.
>>
>>57660748
It says here you have no experience, but the job posting for Junior Java developer explicitly requested 2 years minimum. Can you explain yourself?
>>
>>57664682
i have experience with your mom
>>
>>57664614
Z is an extension of N (because N does not have a group structure). In a group, we need an inverse for each element (assuming the operation is +). So we constructed -1 to be the inverse of 1, -2 to be the inverse of 2...

> inb4 "define what is N"
I can't. It's one of the Peano axioms.
>>
I'm an employed HTML programmer.
>>
#include <iostream>

class Foo
{
public:
void goo() { std::cout << "Goo!" << std::endl; }
};

int main(int argc, char* argv[])
{
Foo foo;
foo.goo();
std::cout << "Address of foo: " << &foo << std::endl;
std::cout << "Address of goo: " << &Foo::goo << std::endl;
std::cout << "Address of goo: " << &foo.goo << std::endl; //illegal operation bound member function expression
return 0;
}


Why can i call a method through a class instance but can't get the address of a method through the class instance?
>>
>>57660748
Hey fellas,

I practicing ruby questions and I'm not sure why exactly my method isn't working.

#Write a method, #rotate(array, shift) that, given an array and an integer (shift), rotates the array in-place by the shift amount.

This is my attack at the problem.
def rotate(array, shift)
new_array = []
idx = 0
while array.length <= shift
new_array << array.unshift(array.pop)
idx += 1
end
return new_array
end
rotate([1,2,3,4],3)

It returns an empty array, why is that?
>>
>>57664960
because every instance of this object uses the same metod
foo.goo() is just syntactic sugar for goo(&foo)
>>
Posted here a couple of times, gotten a bit further with it. I'm doing DirectX 8 hooking via dll injection into an already running process. Because of this, I'm not hooking CreateDevice, rather, creating my own device and using it to get the addresses of the vtable.

I'm having two issues with this. Firstly, it seems I can only do a success CreateDevice call when I'm at the target games menu. If I actually enter the game, the call to CreateDevice will fail. There will either be a stack overflow exception, or a D3DERR_INVALIDCALL. Secondly, after I inject the dll, the target process seems to always try and force itself to be always on top, and not just rendered on top. I can't use any other window, even ones on other screens.

Any ideas what could be causing this? Can post code if need be, but with this explanation code is too many characters.
>>
>>57664970
Look at your example: the length of the array is 4, and the shift value is 3; your while-loop will exit straight away.
>>
File: lena.png (1MB, 900x900px) Image search: [Google]
lena.png
1MB, 900x900px
Hmm, interdasting.
>>
>>57665096
Ps. Just pop and push n number of times. There's nothing much to it.
>>
>>57665035
>because every instance of this object uses the same metod
Yes, i know. So to my mind, &Foo::goo and &foo.goo should give the same result.

>foo.goo() is just syntactic sugar for goo(&foo)
Well, it would be if goo(&foo) was actual syntax that compiled.
>>
>>57665180
address of foo is passed to the method "behind the scenes"

and foo object only has data inside, and maybe a virtual function table. so there is no point in looking up &foo.goo, because it does not exist
>>
>>57665122
explain pls
>>
>>57665096
>your while-loop will exit straight away
why is that? I'm still new to this whole looping thing.
>>
>>57665275
>so there is no point in looking up &foo.goo, because it does not exist
But it obviously must exist in some form, or i wouldn't be able to call foo.goo() instead of foo.Foo::goo() or some shit like that.
>>
>>57660748
It's all how you perceive it, bro.
>>
>>57665297

Working on a new painting effect. I think I'm getting closer to something good.
>>
I need to access an array 1-300 times in Java
Should I call a series of at least 4 getter methods to retrieve the array, for each time I need an array value?

Or should I get the array once, store it as a local variable and then access the data 1-300 times?

The array is originally written in C++, wrapped in java, so there is some effort in accessing it.
I care about performance, as this is for Android
>>
>>57665384
> why is that?
Because, given your example,
rotate([1, 2, 3, 4], 3)

the while-loop will look like
while 4 <= 3
...

4 is never less than or equal to 3, so the loop exits immediately, returning the empty list which you originally declared.

Ruby has a nice method on integers called .times, which executes a block of code n number of times:
def rotate(array, shift)
shift.times do
array.push(array.pop)
end
end
>>
>>57665388
it exists as a part of class, not a part of class instance. it exists somewhere else, it's not inside objects. You can have many objects, but method exists only once. objects don't know and don't need to know where method is
>>
>>57665561
How are you doing this? I would guess v
>Group a bunch of pixels
>Find average colour
>Paint a circle of that colour
>Repeat with random overlapping
>>
>>57665612
>>57665384
PS. Ruby has .rotate on an array anyway.

array.rotate(shift)
>>
File: lena2.png (420KB, 900x900px) Image search: [Google]
lena2.png
420KB, 900x900px
>>57665626

Not quite that simple, but that's the gist of it. I've been iterating on my initial algo for quite a while, and it gives quite an array of customizability.
>>
>>57664437
prove it faggot
>>
>>57665618
Yes i understand all that, except for this part
>objects don't need to know where method is
If objects don't know where a method is, how can a method be called through an object, like so
object.method()
?
>>
>>57665035
So? That explains nothing? Of course I know that. It's a static variable. The thing is that I have to call it with just an implicit this pointer but it tells me it doesn't take zero arguments. What I could do is maybe call it by declaring a void pointer. Taking the address and doing a double dereference while explicitly passing the this pointer so the compiler will compile and do what it's supposed to do.

Anon is really rude for not telling us his trick anyhow. We could all have a grand old time laughing at C++ oddities but instead this mystery just remains.
>>
>>57665682
Anon that's just syntax for objectinstance::method(&objectinstance)
>>
>>57665096
>>57665612
Man, I'm retarded. That's what you meant. Thank you.
>>
>>57665664
That's pretty rad dude. When will you release your application(s) for us to use on our own images?
>>
Hey, so what's the best online flash player tutorial?
>>
>>57665799
>flash player tutorial
what
>>
>>57665723
*sigh* Yes i KNOW! >>57665035 >>57665180

What i don't understand is why &myObject.staticMethod is syntax for &MyClass::staticMethod, but &myObject.method isn't equivalently syntax for &MyClass::method
>>
>>57665682
because that's solved during compilation and linking. and if you look at generated code, it just gets compiled into
 Class::method(&object)

class combines code(methods) and data. object is the data part. if you're looking for methods, look inside code part of class, so &Class::method, not inside data part, don't try &object.method
>>
File: hseximp.png (219KB, 934x865px) Image search: [Google]
hseximp.png
219KB, 934x865px
>>57665751

Maybe at some point. The application itself is more of a testbed for image processing stuff than a real piece of software.
>>
>>57665808
>>57665799
A tutorial on how to programming adobe flash
>>
>>57665838
How do i look at generated code?

So there is absolutely no way in standard c++ to get the address of a method through an object, without having to remember what class the object is an instance of?
>>
>>57665899
It's 2016 bud
>>
>>57665908
I thought that only applied to virtual functions.
>>
>>57665981
Fine, lets start with virtual function. How do i do it with virtual functions?
>>
>>57665940
What does that mean?
>>
>>57666054
People over the age of 13 don't use flash anymore
>>
>>57666007
There's no standard way to do it. You look up the virtual table. Find the object offset in that table or something and look in the table to find the object method pointer. I'm not sure how to do it. If I wanted to do OOP for real in C++ i would implement inheritance myself. Not use the shitty nerf version they provide.
So I haven't touched it. My post didn't mean it was easier. It was that I thought you could take the address of a member function without issue (if not local). I didn't have problems with that in this example.
>>
>>57660786
Getting an allowance doesn't make you employed
>>
File: superiorMind.png (279KB, 898x790px) Image search: [Google]
superiorMind.png
279KB, 898x790px
>>57664419
int average (const int x, const int y) 
{
if ((x < 0) ^ (y < 0))
return (x + y) / 2;
const int xh = x / 2;
const int yh = y / 2;
const int xhr = x % 2;
const int yhr = y % 2;
return xh + yh + (xhr & yhr);
}
>>
Is C# something okay to learn or is it a meme like Python?
>>
>>57666071
>I didn't have problems with that in this example.
Really. So you've tried?
Please to post code.
>>
>>57666129
It's not even a meme, it's just bad
>>
>>57666129
From the impression i have, it's a slightly better Java.
>>
>>57666137
He's asking about C#, not Python
>>
>>57666129
>is it a meme like Python?
explain
>>
>>57666133
See
>>57664960
See what disassembly (or you can just diff the binary) exists at that pointer and compare to the function normally.
>>
>>57666129
C# is great to know.
>>
>>57666179
No wait my bad.
Sorry for the confusion. There was a very similar discussion earlier. I jumped into this at
>>57665707
>>57665723
>>
File: b0204f92be.png (261KB, 1021x768px) Image search: [Google]
b0204f92be.png
261KB, 1021x768px
Working on my terminal emulator, just finished making resizing work on macOS.

This is pretty glorious desu.
>>
>>57660748
How is it possible that the image it's moving if it's a .jpg ?

Am I being memed ? is it an animated gif behind but only named ".jpg" to create confusion

I'm legitimately confus. What wizardry is this?
>>
>>57665908
you can generate asm by compiling with -S flag
or you can disassemble already compiled binary using for example ida pro
>>
File: IMG_0024.jpg (2MB, 4032x3024px) Image search: [Google]
IMG_0024.jpg
2MB, 4032x3024px
Do you think going through my text book that teaches a visual Basic based flow charting software called visual logic and doing all the programming exercises in python is worth the time? Im trying to just convert what i know into a real language since my class only does psuedocode.
Can you guys suggest any other good programming exercises for a begginer to practice basic concepts?
>>
>>57666335
sicp
>>
>>57666289
Why BOOL instead of bool?
>>
>>57666335
go to hacker rank. do all exercises
>>
>>57663834
It uses Semantic versioning.
Major version increases mean breaking changes and that is what Python 3 did.
>>
>>57666370
That's Obj-C bullshit, that's how it's called there.
>>
>>57666289
Are you doing it in rust? Pity i don't know rust.
>>
>>57666067
Youtube uses flash
>>
>>57666398
Only if you're retarded
>>
>>57666393
Yes, it's written in Rust, the terminal is already complete feature wise as far as I'm concerned.

I'm working on porting it to macOS and then Windows.

Then I'll work on either supporting font ligatures or supporting sixels, still have to decide.
>>
>>57666398
for the most part it has moved to html5
>>
>>57666389
Well, huh. https://docs.rs/objc/0.2.2/objc/runtime/type.BOOL.html

Sounds like pain in in the ass.
>>
>>57666289
What's your opinion on Rust?
>>
>>57666428
It is, the Obj-C runtime is awful, Cocoa is awful, foundation is awful.

I'm actually surprised I managed to get it to work considering I never touched anything related to that.

>>57666437
It's the best we have for its niche as far as I'm concerned.

Not saying it's perfect, but it's a really good mix of pragmatism and academic masturbation.

Most of the actual issues I have with the language are being worked on, so I'm not that hopeless about it.
>>
>>57666289
How many loc for the Linux version?
>>
>>57666538
It's sitting at 8 kLOC total currently. But I had to write my own bindings/wrappers for Cairo and Pango.

Cairo and Pango bindings are sitting at 653 lines.

macOS support is sitting at 443 lines.

X11 support is at 579 lines.
>>
>>57666408
I would have been interested in following the development of the Windows port, if only it was done in sepples. I don't feel ready to jump on a new language yet.
>>
>>57666587
That's small enough that I might autistically port it to a different language.
>>
>>57666437
into the trash it goes
>>
>>57666237
>There was a very similar discussion earlier.
Yeah, i've been trying to solve anons problem. Mostly to just learn something for myself.

Anyway, heres the best i could come up with, what to me looks closest to what anon was trying to achieve.
#include <iostream>

class Foo
{
public:
void goo() { std::cout << "It werks!" << std::endl; }
static void (Foo::*bar)();
void callBar() { (this->*bar)(); }
};

void (Foo::*Foo::bar)();

int main(int argc, char* argv[])
{
Foo foo;
foo.bar = &Foo::goo;
foo.callBar();

return 0;
}


The only thing that bothers me is the line
>foo.bar = &Foo::goo;
I would like to replace it with something to the effect of
>foo.bar = &typeof(foo)::goo
>>
File: 1455696071419.jpg (55KB, 692x577px) Image search: [Google]
1455696071419.jpg
55KB, 692x577px
>mfw know Math/Physics/Electronics and shit but can't use that
>mfw learning C programming for 1 year and can't do any serious shit
>mfw know Unix, Linux, Bash shell, Vim and can't get a job
>mfw know networking and Hardware/Software troubleshooting and can't even get a job as a help desk

I've learning all this shit for already 1+ years and literally can't do anything serious, I'm 19 years old and know many things(*I'mn't edgy, besides I've really low self-esteem) many people won't be able to learn for this age.

I've already have suicidal thoughts, because I've been learning C for 1 year and still are stuck in a pile of dogshit.

>Just kill me now
>>
>>57666624
>>57666660
They're not ports to different languages, I just add the platform dependant layer, the rest of the code is the same.
>>
>>57666720
Learn some higher level stuff and how to engineer software properly. That is what gets you a job most of the time, not the lower level stuff.
>>
File: zed.jpg (117KB, 940x492px) Image search: [Google]
zed.jpg
117KB, 940x492px
reddit again gets btfo by zed shaw

https://zedshaw.com/2016/11/24/the-end-of-coder-influence/
>>
>>57666690
I don't see the point of that replacement. While goo isn't static it's not inherent to any class instance.
I just don't see the need for that translation or the problem with the original.
>>
>>57666720
how do i unsubscribe?
>>
>>57666732
Yeah, i was saying i would be interested in how you do the Windows dependent layer.

The other anon, as i understood it, said they were interested in porting your work to another lang.
>>
>>57666751
didn't he say python 3 isn't turing complete because it isn't backwards compatible with python 2?
>>
>>57666720
What have you done? Where/why do you feel inadequate? What do you think is required to get a job?
Do you have any idea of what you don't know?
>>
>>57666787
Yes
>>
>>57666796
so why does he feel qualified to have a blog, let alone write books?
>>
>>57666787
yes, he's good at trolling cs101 students
>>
>>57666783
I see, it's mostly boring stuff, just use the low level win32 bullshit to create the window and convert the events and whatever to the internal stuff, create the Cairo surface, the rest just works.
>>
>>57666750

but I want to finish learning C programming and it's also very useful in Electronics(microcontrollers, PLC etc) also for Robots programming and LL in general.
>>
>>57666813

Dunning–Kruger effect
>>
>>57660748
whichever one I'm not focused on
>>
>>57666732
You misunderstand, I plan to douse it in CLR
>>
>>57666772
In a tiny example like that, there's no need beyond just gaining proficiency with the language.

But i'm thinking in a larger project there might hypothetically be a cause to do that, for the same reasons that polymorphism is a thing.
>>
>>57666791
getting job isn't my problem, I just can't use my knowledge and it's makes me nervous.
I wonder how my motivation keeps me learning those things, because another person would leave everything behind.
>Do you have any idea of what you don't know?
Yes
>>
File: 1479649527171.png (520KB, 597x963px) Image search: [Google]
1479649527171.png
520KB, 597x963px
Anyone know how I can improve this C# code for converting between bits, bytes etc. Started a few weeks ago.

https://ghostbin.com/paste/mp8xa
>>
>>57666830
Give it time. It takes long to become proficient in programming. People literally dedicate their lives to this field - shows you how much there is to learn.

You can always learn both C and engineering principles.
>>
File: i-am-right.png (162KB, 722x650px) Image search: [Google]
i-am-right.png
162KB, 722x650px
>mfw know algebra, highschool physics, and took honors electric engineering and shit but can't use that
>mfw top of my class in AP Computer Science
>mfw followed youtube C programming tutorials for 1 month and can't do any serious shit
>mfw know Unix, Linux, Windows, Android, iOS, Bash shell, know the commands :w and :q! on Vim and can't get a job
>mfw read wikipedia pages on networks and Hardware/Software troubleshooting articles i found on google and can't even get a job as a help desk

I've learning all this shit for already a couple months and literally can't do anything serious, I turned 18 years old a week ago and know many things(*I'mn't edgy, besides I've really low self-esteem) many people won't be able to learn for this age (I know i'm extremely intelligent for my age, I'm smarter than people older than me, but no one believes me).

I've already have suicidal thoughts, because I've been learning C for 1 year and still are stuck in a pile of dogshit. I'm indian and can barely speak english

>Just kill me now
>>
As a data scientist, I tough I will give an opportunity to haskell, so I got (download) the book "Haskell Data Analysis Cookbook".

I know the book has been writen by some random pajeet, but he real question is how is this
import Text.CSV

-- Parses a CSV file
main :: IO ()
main = do
let fileName = "input.csv"
input <- readFile fileName
let csv = parseCSV fileName input
either handleError doWork csv

handleError csv = putStrLn "not a CSV"
doWork csv = (print.findOldest.tail) (filter (\x -> length x == 2) csv)

-- Finds oldest person.
findOldest :: [Record] -> Record
findOldest [] = []
findOldest items = foldl1 (\a x -> if age x > age a then x else a) items

age [a,b] = toInt b

toInt :: String -> Int
toInt = read

more concise and elegant than
import pandas
table = pandas.read_csv("input.csv")
print table[table.age = max(table.age)]

?
I have imported an specialized csv library for haskell, why should I reinvent the wheel?
>>
>>57666828
>it's mostly boring stuff, just use the low level win32 bullshit to create the window and convert the events and whatever to the internal stuff, create the Cairo surface,
That's the parts i'm kind of interested in learning.

I was thinking it might be helpful to look at a program that actually does something useful, while daily progress instead of a finished thing might mean it doesn't feel overwhelming.

Although from your progress reports her on /dpt/, you work fast compared to me.
>>
>>57666852
Yeah well c++ doesn't do runtime introspection afaik. You could probably get quite far with decltype and templates. But I don't see any good way to say return the address of whatever was the first declared method of a class.

Maybe some implementations of reflection can do that. But I'd imagine that kind of a thing is very compiler specific either way.
>>
File: IMG_9496.jpg (65KB, 411x412px) Image search: [Google]
IMG_9496.jpg
65KB, 411x412px
>>57666905
loner lmao
>>
>>57666925
I guess the least boring stuff is Windows doesn't support any of the fork/openpty bullshit, so I'll have to figure out how the fuck to do that.

But I should be done in a couple days with the Windows stuff. Like I was done in a couple days with macOS.
>>
>>57666905

stick sarcasm in your ass, I don't think that I'm smarter than anybody, and I'm not indian or pajeet.
>>
>>57666957
yes mr. Shafiq Khan Mohammad
>>
#if defined(_WIN32) || defined(_WIN64)
#error "Windows"
#elif defined(__linux__)
#error "Linux"
#else
#error "Unknown compile Operating System"
#endif

Will this work as intended on notMSVC?
>>
>>57666907
if you can't use it then isn't for you, just use what it works
Haskell is good enough as it is
>>
>>57666990

I'm not internet or 4chan beginner to get butthurt about sarcasm, I'll just tell you to fuck off.
>>
>>57667023
>le edgy oldfag
>returning once again from le reddit
>>
>>57666907
filename = "input.csv"

main =
(parseCSV filename <$> readFile filename) >>= process

findOldest = maximum . map age

age :: [String] -> Int
age [_, b] = read b

process (Left err) = putStrLn "Not a CSV"
process (Right val) = (print . findOldest . tail . filter ((==2) . length)) val
>>
What does /dpt/ think about Racket?
>>
>>57667036
just stop it now! i can not take it, you are so rude
>>
>>57667075
Please consider a less harmful alternative such as Guile.
>>
>>57667098
tell me more about how you include vim on your resume rajesh
>>
File: oldfogeyenthusiasm.png (817KB, 798x602px) Image search: [Google]
oldfogeyenthusiasm.png
817KB, 798x602px
Just submitted my first pull request to someone else's open source project. Feels good man
>>
>>57667109
the name is Harikiran Divyansh Samar Yakshit
>>
>>57667068
whoops, misunderstood findOldest

findOldest = head . sortBy (compare `on` age)
-- sortBy in Data.List
-- on in Data.Function
>>
>>57667106
What do you mean by harmful?
>>
>>57667109

I'm looking for a job or sending CVs, shut up pajeet
>>
>>57667163
http://harmful.cat-v.org/
>>
>>57667137
gg m8. What's the project about? How did you go about finding a project you wanted to contribute to?
>>
>>57667195
I wonder that too. The only shit I can find to contribute are crappy test cases for crappy undocumented software.
>>
>>57661981
yes it does
https://ideone.com/BrvLFm
>>
>>57667195
It's a wrapper for FMOD sound system for an engine I like. It missed some features I wanted so I just decided to add them. It's not a big project by any means though
>>
>>57667179
That site was so autistic the founder killed himself.
>>
>>57660748
AI program..python
>>
>>57667011
>_win32
Iirc that doesn't exist in msvc. Which is the primary compiler on Windows.
Depends on your goal. Maybe on LLVM on Windows.

But yeah if those defines exist as expected that's fine.
>>
>>57667275
why not doing it in haskell?
>>
>>57667261
Not an argument
>>
>>57667106
guile is shit compared to racket.
>>
>Prelude.read: no parse
WTF does that even mean?
disarm (White:xs) = True
causes the issue.
import System.Environment

data Wire = White | Black | Purple | Red | Green | Orange
deriving(Read)

disarm :: [Wire] -> Bool
disarm (White:xs) = True
disarm _ = True

main :: IO ()
main = do
args <- getArgs
putStrLn . show . disarm $ map read args
return ()
>>
>C# and Java still don't even have applicative functors
Why do these languages still exist?
>>
>>57667011
To be safe use
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
>>
Just move to the new one.

>>57667266
>>
>>57667068
>>57667142
*last
not head

>>57666907

Anyway, the reason you should prefer this is
1) It is strongly typed
2) It can be compiled and is probably faster (barring Python's tendency to just be a facade for C code)
3) It is more flexible

The python library isn't the same as the Haskell example.

Here's what it would be like if the Haskell library were written similarly

readCSV :: FilePath -> IO [Record]
(library)

main = readCSV "input.csv" >>= work
work = last . sortBy (compare `on` age) . filter ((2==) . length)
>>
>>57667368
Racket is harmful software, please consider an alternative such as Guile or MIT/GNU Scheme.
>>
>>57667394
explain how it's harmful
>>
>>57667282
I don't think you remember correctly.

But it's possible other windows compiler, ex. MinGW, doesn't have those defines, i guess.
>>
>>57667373
No parse means the parsing failed.
It's not very descriptive, sadly.
And Prelude has a bunch of ill-typed holdovers like that - read will throw exceptions if it fails to parse. So one of them didn't parse.

another way of writing main is
main = getArgs >>= mapM_ (print.disarm.read)

print = putStrLn . show
>>
>>57667386
so three lines vs three longer and confusing lines (you forgot to import)
btw, the python version can be done in two, if that crappy function concatenation is allowed
>>
>>57667461
I didn't find the lines confusing but I'm used ot haskell

Now please explain to me what in the fuck
table[table.age = max(table.age)]
is meant to mean
>>
>>57667461
And the Python version is slower and subtly broken, congrats.
>>
>>57667487
It means TypeError.
>>
>>57667487
it's self descriptive and even functional in a group theory sense, so the question is "what's wrong with you?"
>>
>>57667498
pandas never flipped a bit on tables of at least 15GB
>>
Python users:
>hurr
(+) x y
makes no sense but x + y is fine
>hurr
x `f` y
makes no sense
>hurr f x makes no sense but f(x) is fine
>>
>>57667529
>it's self descriptive
You're taking the maximum of a single value and then assigning it to itself?
Genius
>>
>>57667563
guess who got an F in algebra?
>>
>>57667542
Not talking about flipped bits, moron.
>>
>>57667581
Python users

I'm sure about 80% of them are functionally illiterate, and 90% are innumerate.
>>
>>57667589
then I don't see your point
>ad hominem
>>
>>57667609
And this is the problem with Python users, they don't know how their code is broken because there's no compiler to point it out to them.
>>
>>57667605
that's why there are so many physicist using it right?
>>
>>57667645
Because they're illiterate and innumerate (if they weren't they'd be able to use something better!)
>>
>>57667645
>physicist
>not physicists
couldn't match type Person with expected type [Person]
>>
>>57667623
It didn't ever flipped a bit, then works wonders on big data. No matter what the compiler says.
>>
>>57667676
You really have no clue, do you?
>>
>>57667692
do you?
>>
>>57667702
Yes
>>
Who here think <xml a="shit" />?
>>
>>57667720
well, guess who got the job between us?
>>
>>57667755
Well, I have a job, so I guess it was me.
>>
jerking at anime isn't a job you know?
>>
>>57667792
I'm not at work, today is Thanksgiving, idiot.
>>
>>57667827
so, you don't jerk in thanksgiving?
>>
>>57667863
I might do, but it's not a job, I enjoy doing it (don't you?)
>>
>>57667903
I prefer to make my woman do it, but yes, I forgot for a moment I was speaking with a haskell fundamentalist
>>
>>57667919
Oh I see, you only get any action on holidays. I'm so very sorry to learn that.
>>
>>57667943
not that you can learn anything at all
>>
>>57667971
True, I already learned Haskell, there is nothing else left to learn.
>>
>try to send something using avr usart
>receive garbage
so many things could be wrong I don't even know where to start
>>
If your language cannot express

traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()


then it is not a language worthy of use.
>>
File: 1476600708574s.jpg (2KB, 114x125px) Image search: [Google]
1476600708574s.jpg
2KB, 114x125px
>>57664922
>>
>>57668237
that was easy. actual baud was different from expected one because of hardware limitations
>>
>>57667971
>>57667982
I like the conversation you both just had.
Australian / British anons?
Thread posts: 364
Thread images: 28


[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.