[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 20
old thread: >>54006217

What are you working on, /g/?
>>
nothing but thanks for asking i appreciate it
>>
tfw shit at design patterns. i know how to make most anything work but cant organize my shit nicely
>>
File: akari2.jpg (58 KB, 514x524) Image search: [Google]
akari2.jpg
58 KB, 514x524
Rate my tripcode generator!
https://github.com/microsounds/tripforce

TRIP: '!s6AKARI0gc' -> PASS: '_6U>2'tb' @ 304.57 kTrip/s
TRIP: '!SwJ3takARI' -> PASS: '2:nT``ZZ' @ 308.14 kTrip/s
TRIP: '!Fn6daKarIE' -> PASS: 'Bu_p`"=4' @ 307.80 kTrip/s
TRIP: '!kMAkaRiBhs' -> PASS: 'RK{Xi;:N' @ 307.79 kTrip/s
TRIP: '!kYMXgakArI' -> PASS: 'i:3gF9aW' @ 308.69 kTrip/s
TRIP: '!qGAkArIfT2' -> PASS: 'NrB)S=73' @ 308.28 kTrip/s
TRIP: '!nSSgbAKArI' -> PASS: 'pXtIo30]' @ 309.27 kTrip/s
>>
>>54010519
Prove it.

Also, can we all agree that this is ugly to look at:
(i=0; i<100; i++)
>>
File: Untitled.png (776 KB, 840x1010) Image search: [Google]
Untitled.png
776 KB, 840x1010
>>54010519
by fifteen seconds. somehow I think you already knew that.
>>
File: 2016-04-12 20_23_33.png (126 KB, 1803x826) Image search: [Google]
2016-04-12 20_23_33.png
126 KB, 1803x826
Linearizing equations. Fun stuff...
>>
>>54010512
.Dd April 11, 2016
.Dt TRIPFORCE 1
.Os
.Sh NAME
.Nm tripforce
.Nd tripcode generator
.Sh SYNOPSIS
.Nm
.Fl h
.Nm
.Op Fl i
.Op Ar searchstr
.Sh DESCRIPTION
.Nm
generates tripcodes that contain
.Ar searchstr .
.Pp
If
.Ar searchstr
is omitted, then
.Nm
will print random tripcodes to standard output.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl i
Do a case agnostic search.
.It Fl h
Show a brief help message and exit.
.El
>>
nice programming thread guys
>>
File: XGYM21g.jpg (846 KB, 1920x2560) Image search: [Google]
XGYM21g.jpg
846 KB, 1920x2560
well this went to shit
>>
>>54010806
>She
>>
>I don't even know any of these characters except for makishit
What have I been doing in my life
>>
>scantily clad anime girls in /DPT/
>>
Guys lets work on the captcha solver programming collab
>>
Where are the janitors?
>>
>>54010985
Busy deleting interesting on-topic threads.
>>
great thread (y) <thumbs up emojicon
>>
>>54011028
>drawing saika with boobs
this isn't funny
>>
>>54011060
>boobs
>have you even felt them
>/g/
>>
>>54011097
let's all be friends, ok?
>>
>>54011097
I accidentally touched my managers boobs quite a few times

She didn't even notice
>>
>>54011060
Yes, there is an upward limit though to the visual appeal to me though.
>>
>>54010400
CAN THE MODS DO SOMETHING ABOUT THIS SHITPOSTING FOR FUCK SAKE
>>
#include <stdio.h>

int main()
{

int i;

for (i = 1; i <= 100; i++ )
{
if ((i%3 == 1) && (i%5 == 1))
{
printf("FizzBuzz\n");
}
if (i%3 == 1)
{
printf("Fizz\n");
}
if (i%5 == 1)
{
printf("Buzz\n");
}
}

return 0;
}
>>
>>54011170
YES DELETE THIS FORCED TRAP SHIT
>>
COME HERE FOR THE REAL THREAD >>54011209
>>
>>54011174
This desu.
I like dudes though, so I'm biased.
>>
File: 1407905937240.jpg (23 KB, 500x375) Image search: [Google]
1407905937240.jpg
23 KB, 500x375
>>54011197
>== 1
>>
what's the better way of doing this? in Jabba
if (i==0)
{
object.param = kektus.x
object.param = kektus.y
}
if (i==1)
{
object.param = yourmom.x
object.param = yourmom.y
}
if (i==2)
{
object.param = nigger.x
object.param = nigger.y
}
>>
>>54011245
AbstractFactoryBean
>>
>>54011245
switch (i) {
case 0: obj = kektus; break;
case 1: obj = yourmom; break;
case 2: obj = nigger; break;
}
object.param = obj.x;
object.param = obj.x;
>>
>>54011245
you're doing it wrong
>>
>>54011273
thank you~
>>54011309
I know, fuck off
>>
>>54011320
Fuck off, retard.
>>
>>54011273
obj[] array = {kektus, youremom, nigger};
object.param = array[i].y;
>>
File: 1449031833665.jpg (6 KB, 200x200) Image search: [Google]
1449031833665.jpg
6 KB, 200x200
>>54011320
no.
>>
Programming seems pretty fun.
>>
lets herd sum catz
>>
>>54011385
The challenge websites are the only reason I'm constantly improving. It's so hard to find direction on your own from a beginners stand point at least for me.
>>
Why does everyone use some kind of meme unit testing framework when I can just make a new .cpp, import headers I want to test, add
if(expected != actual){ errors++ } or assert(expected == actual) and output results to file?
>>
  1 #include <stdio.h>
2
3 int main()
4 {
5
6 int i;
7
8 for (i = 1; i <= 100; i++ )
9 {
10 if (i%15 == 0)
11 {
12 printf("FizzBuzz\n");
13 }
14 else if (i%3 == 0)
15 {
16 printf("Fizz\n");
17 }
18 else if (i%5 == 0)
19 {
20 printf("Buzz\n");
21 }
22 else if (i%3 != 0 || i%5 != 0 || i%15 != 0)
23 {
24 printf("%d\n",i);
25 }
26 }
27
28 return 0;
29 }

Is fizzbuzz still cool?
>>
>>54010995
this, big tits are fucking nasty
>>54011174
agreed
>>
>>54011708
>else if (i%3 != 0 || i%5 != 0 || i%15 != 0)
>>
>>54011708
>4 ifs
>hard coded 100
Don't call us we'll call you.
*throws resume in trash*
>>
>>54011734
Well desu dude I just got done learning break and continue... Cut some slack X)
>>
>>54011717
>!nv.0k6WoTc
opinion discarded
>>
>>54011756
nice dude
>>
>>54010995
>>54011717
Get the fuck out, faggots.
>>
Does data mining go in here as well?

I am working on a script to see voter overlap b/w both parties' candidates for the presidential election on a state/county level.
>>
>>54011917
What are you writing it in and how does it work basically?
>>
>>54012002
I am breaking down results by state (then county) and seeing if there is any similarities b/w % votes for the winners in each party. I was thinking of doing it in python b/c that's easiest, but I kind of want to try making it into a node.js app to get more practice.
>>
>>54012074
How are you getting the data and going to analyze it?
>>
int printf(const char *, ...);

char * c[] = {"fizz","buzz"};

int fizzbuzz(int a, int b)
{
return (a%b--) || !(printf(c[b/2-1]));
}

int main(int argv, char ** argc)
{
int i = 0;
while (i++ < 100)
{
fizzbuzz(i, 3) & fizzbuzz(i, 5) && printf("%i", i);
printf("\n");
}
return 1;
}


please hire me
>>
>>54012305
This json file from NY Times
https://int.nyt.com/applications/elections/2016/api/election/primaries.json
used for
http://www.nytimes.com/interactive/2016/us/elections/primary-calendar-and-results.html
There are a ton of data sets released by US the govt that are a gold mine. Figured this topic would be a good launching point since it's recent.
>>
>>54011734
How would you avoid hard coding 100?
>>
File: 1409612744342.png (197 KB, 600x300) Image search: [Google]
1409612744342.png
197 KB, 600x300
Before today I didn't even know about littleEndian vs bigEndian. How useless.

>Does endianness matter for programmers?
Most of the times compiler takes care of endianness, however, endianness becomes an issue in following cases.

>It matters in network programming: Suppose you write integers to file on a little endian machine and you transfer this file to a big endian machine. Unless there is little andian to big endian transformation, big endian machine will read the file in reverse order. You can find such a practical example here.
>>
>>54012450
Hard coded means it will only work up to 100, or in other words. It means there are no variables involved.

If you wanted to do the fizzbuzz up to 900 you would need to technically rewrite the code.

you could avoid this by using a variable instead.
>>
>>54010400
Stop this programming trap meme.
>>
void fizzbuzz()
{
int multiples_of_three_until_one_hundred[] = {3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 0};
int multiples_of_five_until_one_hundred[] = {5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 0};
int multiples_of_three_and_five_until_one_hundred[] = {15, 30, 45, 60, 75, 90, 0};

for (int i = 1; i <= 100; i++)
{
bool is_a_multiple_of_three_and_five = false;
for (int j = 0; j++)
{
if (multiples_of_three_and_five_until_one_hundred[j] == 0)
break;
else if (multiples_of_three_and_five_until_one_hundred[j] == i)
{
is_a_multiple_of_three_and_five = true;
break;
}
}
if (is_a_multiple_of_three_and_five == true)
cout << "Fizzbuzz" << endl;
else
{
bool is_a_multiple_of_five = false;
for (int j = 0; j++)
{
if (multiples_of_five_until_one_hundred[j] == 0)
break;
else if (multiples_of_five_until_one_hundred[j] == i)
{
is_a_multiple_of_five = true;
break;
}
}
if (is_a_multiple_of_five == true)
cout << "Buzz" << endl;
else
{
bool is_a_multiple_of_three = false;
for (int j = 0; j++)
{
if (multiples_of_three_until_one_hundred[j] == 0)
break;
else if (multiples_of_three_until_one_hundred[j] == i)
{
is_a_multiple_of_three = true;
break;
}
}
if (is_a_multiple_of_three == true)
cout << "Fizz" << endl;
else
cout << i << endl;
}
}
}
}
>>
how does unique_ptr work again, is this correct?
void eatIt(std::unique_ptr<Apple> app) {
app->kek();
app.release();
}

int main() {
auto app = std::make_unique<Apple>();
eatIt(std::move(app));

app.reset();
return 0;
}
>>
http://pastebin.com/aH8BvMmY
r8 my fizzbuzz
>>
>>54012491
LOLWUT. You know the point of fizzbuzz is to print from 1 to 100. It's in the task description. Using a variable to store a const value is pointless.
>>
>every entry level programming job in my city is web dev or mobile app dev
>mobile app dev requires prior experience

fugg
>>
>>54012572
You missed out on nothing
>>
File: S5GoaXq[1].jpg (12 KB, 192x286) Image search: [Google]
S5GoaXq[1].jpg
12 KB, 192x286
>>54012533
>>
Alrighty then.
>>
>>54012579
Optimization doesn't matter m8 performance doesn't matter CPUs can run ANYTHING nowadays
>>
File: latest[2].jpg (39 KB, 900x900) Image search: [Google]
latest[2].jpg
39 KB, 900x900
FUCKING JAVASCRIPT THIS IS THE WORST LANGUAGE I'VE EVER USED

I WISH I COULD SLAP THE FUCKER WHO INVENTED IT

REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

>No concurrency
>Shitty community
>Shitty typing
>Shitty documentation on nearly every npm packages
>90% of the package are one liners importing another library because everyones wants to have over 500 packages for who knows what reason
>The language itself is full of mistakes

I even went to a javascript seminar last year and a talker said: "yeah it's a good language, but the main problem is that it's hard to maintain". Why the fuck would you use something hard to maintain on a big project?
>>
>OP image deleted
Trapfags BTFO
>>
>mods remove the thread with actual discussion for this piece of shit thread
>>
Been studying CS for about a year in school/alone, but I've always been interested in how malware/viruses work and are removed by antiviruses. After some light googling, there aren't many resources I could find on the surface that go into any depth about either.

Say I'm interested in how they work, what could I read, or programming concepts to learn, to better understand them? I do have a junker computer to just install them on, though even then I'm not sure how to start studying the infection.
>>
>>54012597
Retards like you are the reason we can`t have nice things. >>>/gtfo/ and take your bloated shit with you, why does everyone seem to think "hurrrr durrr moores law means we can write resource hogging horse shit and not give a fuck about performance"???
>>
>>54012674
>why
java. that's why.
>>
>>54012634
Search danoct or rogueamp on youtube. Look up malware on github to analyze.
>>
>>54012691
nice meme kid
>>
>>54012702
He's not wrong
>>
>>54012626
javascript isn't a language mayne.
>>
All memes aside, is C++ good?

I use C at work, but want to learn a language that's good for cross-platform desktop development, and has some more abstraction and libraries than C has.
>>
>>54012753
Yes
>>
>>54012753
>is C++ good
No
>>
>>54012634
Pillage the sauce code section of script kiddie sites like hack forums and oday.in.
>>
>>54012753
yea c++11/14/17 is good

just don't use raw pointers or other obsolete features
>>
>>54012846
Any good resources on those?
The extent of my C++ knowledge is that there are dynamic arrays, a string type, and classes. So I don't know much about C++.
>>
>>54012846
>other obsolete features
like?
>>
>>54012753
It's the best imperative programming language by far. It's not good in a vacuum, but it strikes the best balance of practicality and convenience out of all available options.
>>
>>54012846
What are raw pointers?
>>
>>54012913
Uncooked pointers.
>>
>>54012913
Non-smart-pointers
>>
File: output.webm (2 MB, 802x458) Image search: [Google]
output.webm
2 MB, 802x458
>>
>>54012880
oh just read The C++ Programming Language 4th edition, it covers the new shit
then maybe after a while try out Modern Effective C++ by meyers
>>
What would be the time complexity of running a recursive function 4 times?
int my_function()
{
//code

return my_function() + my_function() + my_function() + my_function();
}
>>
>>54012913
raw:
int* myInt = new int(5);

smart:
std::shared_ptr<int> myInt(new int(5));
>>
>>54012962
O(n)
>>
>>54012966
So smart pointers are slower and take up more RAM?
>>
>>54012977
No, they prevent stupid programmers from doing stupid things
>>
>>54012913
raw is the C way
smart pointers are this (C++14)
std::unique_ptr<Nig> kek = std::make_unique<Nig>("yo ayy");


just google smart pointers
>>
>>54012977
R E A D I M P L E M E N T A T I O N
>>
>>54012977
it's all compile time
>>
Where does /dpt/ look for programming jobs?
>>
>>54013035
I send my resume out to hundreds of jobs on indeed.com and get 0 responses.
>>
>>54012977

Shared pointers might take up a little bit of extra RAM for the reference count.

Unique pointers don't really need to contain more than the pointer itself.

Neither is really "slower". Any reasonable compiler will inline the destructor if it's trivial, in which case, it'd just be like if you just typed in delete at the end of your function.
>>
>>54012977
in the case of unique_ptr there is just a thin layer over the raw pointer. it's not slower and it barely takes more RAM. share_ptr and weak_ptr take up a bit more memory (but not much) and have a few atomic operations that are done behind the scenes on occasion, but the cost is so small compared to what you gain.

use them. they are superior.
>>
>>54013050
same, except I get like three. After a month and like five interviews though, it all works out.

For an autist with a speech impediment, I apparently come off surprisingly qualified in person
>>
>>54013035
Network at a job fair. >>54013050 will work eventually but it gets frustrating real fast. Also applying to places outside of CA helps if you are willing to move.
>>
>>54013093

Lucky bastard. Having a disability makes the employer feel sorry for you.
>>
>>54012995
Smart pointers are C++11 too.
>>
>>54013201
the C++14 part is
std::make_unique<Type>();
>>
>>54013193
It's a minor enough speech impediment that I can hide it for a short amount of time by being succinct and carefully planning what I say. I don't report any disabilities on my applications because I don't want to be excluded because of it.
>>
>>54013213
Ah I gotcha
>>
>smart/raw pointers
>not putting literally everything on the stack or using references
wew
>>
>>54013253
>>not putting literally everything on the stack

okay buddy
>>
So there's an autsitic curry behind me in my software engineering class

He fulfills the stereotype of the enterprise curry by regurgitating the book and when the prof doesn't call on him he whispers the answer to himself
>>
>using global variables for everything
>>
>>54011365
the best solution
>>
>>54013275
Not passing every variable as a parameter for every function
>>
I know only basic Java, how long would Android Studio take to learn enough to make BASIC apps with a basic ui?

I just want android studio familiarity + a project to show for it on resume/github
>>
>>54013274

he dreams in design patterns. you should be more like him.
>>
>>54013293
https://www.udacity.com/course/developing-android-apps--ud853
>>
>>54010400
My MinGW installation manager says I have gcc 4.9.3-1 installed but when I do gcc --version in PowerShell it says I have 4.6.3. What's going on?
>>
File: qqqqq.jpg (127 KB, 500x500) Image search: [Google]
qqqqq.jpg
127 KB, 500x500
Where would I look to figure out how windows sets a wallpaper? Everything I google turns up with "How to set your windows wallpaper!". The only place that I can think to look is the VLC source code because it has the ability to play a video as the wallpaper.
>>
>>54012946
>flappy bird
>has no flapping
0/10 you could do it in emacs
>>
>>54013253

Where dynamic memory is needed, or large quantities of memory are needed, the stack should not be used.
>>
>>54013260
>not putting literally everything in registers
we'll call you
>>
>>54013384
find out where you have it installed, you might have 2 gcc's somewhere
--version should show the location
>>
def fizzBuzz(n):
def foo(w):
acc = ""
if w%3 == 0 : acc += "Fizz"
if w%5 == 0 : acc += "Buzz"
if acc != "": print acc
for i in range(n): foo(i)
>>
>>54013436
SystemParametersInfo
SPI_SETDESKWALLPAPER SPIF_SENDWININICHANGE
>>
>>54013488
is there any reason to use foo() at all
why not just put the 'acc = "" ... print acc' inside the for loop
wtf
>>
File: flappy-vim.webm (962 KB, 802x458) Image search: [Google]
flappy-vim.webm
962 KB, 802x458
>>54012953
>>54013443
Here's an updated version. Unfortunately the update doesn't make me better at the game.
>>
>not using emacs
https://www.youtube.com/watch?v=D1sXuHnf_lo
>>
>>54013510
just because you can in python
functions inside functions inside functions inside functions inside functions inside
>>
>>54013293
Android spoon feeds you a lot of things. Mostly just look at the design patterns that Android uses and look up some functionality that you need.
>>
data PrintableTree =
PrintableLeaf String
| PrintableTree String [PrintableTree]

instance Show PrintableTree where
show tree =
let { showAtLevel lvl (PrintableLeaf label) = showLabel lvl label

; showAtLevel lvl (PrintableTree label children) =
(showLabel lvl label) : liftM (showAtLevel $ lvl + 1) children

; showLabel 0 label = label

; showLabel lvl label =
(replicate (3 * (lvl - 1)) ' ') ++ "|- " ++ label
}
in
intercalate "\n" $ showAtLevel 0 "" tree
>>
>>54013560
Sorry, I'm a fucking newtard and didn't know how to add content as code :(

data PrintableTree =
PrintableLeaf String
| PrintableTree String [PrintableTree]

instance Show PrintableTree where
show tree =
let { showAtLevel lvl (PrintableLeaf label) = showLabel lvl label

; showAtLevel lvl (PrintableTree label children) =
(showLabel lvl label) : liftM (showAtLevel $ lvl + 1) children

; showLabel 0 label = label

; showLabel lvl label =
(replicate (3 * (lvl - 1)) ' ') ++ "|- " ++ label
}
in
intercalate "\n" $ showAtLevel 0 "" tree
[\code]
>>
>>54013512
fucking hell man
Did you do this in VimL? What would move you to do such a thing?
>>
>>54013603
autism
>>
>>54013603
Yeah, it's VimL. Quite poorly written too with lots of hardcoded shit and usage of :normal. It's just for fun.
>>
>>54013647
Post code. It shall go down in the /dpt/ autism hall of fame.
>>
test
>>
>>54013647
Two questions:
How long/how much effort did you put into learning VimL to do this?
How long did this take to make?

Of all things to learn, VimL seems so niche.
>>
>>54013656
this to t be b honest h
>>
>>54013529
>american fitz
whoah
>>
Do any of you anons want to start a project with me? It can be whatever; games, not games, whatever language. I was thinking some game in lua with Love2D or something similar.
I do uni stuff, but I've never really followed anything of my own to completion, because I just always lose interest, or aren't enthusiastic enough, etc. I think working with someone else would be a good way to maintain morale.
I'm a little green, but I'm a competent programmer, essentially better than any of the fellow students I've seen (I have seen some a-grade shit though. I dunno how half of these people haven't dropped out)
I can use git, too.
>>
>>54013510
lets keep going down the functional train
let fizzBuzz n = 
let rec helper n' =
if n' > n then ""
else
if n' mod 3 = 0 && n' mod 5 = 0 then "FizzBuzz " ^ (helper (n'+1))
else
if n' mod 3 = 0 then "Fizz " ^ (helper (n'+1))
else
if n' mod 5 = 0 then "Buzz " ^ (helper (n'+1))
else "" ^ (helper (n'+1))
in helper 0
>>
>>54013714
I'll collab with you on whatever you'd like so long as it's in C89.
>>
>>54013664
I just started learning VimL a few days ago. I had written maybe 200loc in total before i did this. The first webm I uploaded was after maybe an hour and the second one was around 45 minutes of coding later. So around 2 hours I guess. I had to spend like 10 minutes recording too cause I wasn't any good at the game. The whole script is just under 200loc. I might upload it to github but then I'll have to fix some of the more embarrassing solutions first.
>>
>>54013465
I found the problem. My Haskell Platform had its own outdated copy of MinGW that was higher in the environment variables tree than MinGW. I just added MinGW\bin and put it at the top of the list.
>>
>>54013726
I would like to amend my initial request to not say "whatever language".
>>
>>54013730
Oh okay, shit lol
I honestly thought you spent like weeks learning VimL or something. I guess Vim is just a platform I have no experience programming with (just using it) so I thought making a game like that was really impressive and probably difficult

Right on though; don't worry about embarrassing lines, this is gonna be a cult classic. I'd play it when I get held up programming lol
>>
>>54013820
It is impressive, VimL is cancer
>>
>>54013750
>i'm a competent programmer
>i don't like C

wow dude
>>
>>54013714
i only collaborate with professional programmers such as my self and my coworkers and my boss.
>>
>>54013735

Why do people think it's okay to use outdated versions of GCC? I've done work on supercomputers fairly recently, and they're using shit like GCC 4.4. What the fuck?
>>
>>54013883
For the same reason businesses pay for Winrar, so they know nothing will fuck up.
>>
>>54013883
I haven't updated or used Haskell in a long time, so it's not like it's their fault.
>>
>>54013820
Yeah VimL is peculiar in some ways but the syntax looks like basic pretty much. If you have done any basic/python/bash scripting and you're familiar with vim commands it seems to come naturally. The main issue if you are (for some reason) making games is of course that vim doesn't support asynchronous execution, but for this game this issue could easily be avoided since it's just one button.
>>
lua_getglobal( L, "object" ); //object table
lua_rawgeti( L, -1, i + 1 ); //object ID
lua_getfield( L, 1, "update" ); //update function

if( lua_pcall ( L, 0, 0, 0 ) != 0 )
lua_error( L );


what am I doing wrong, /g/?

I want to get a function with a table array and call it

I've had luck getting a table and setting a value in it, but i've never worked on the array part in C
>>
a=[[1,2],[3,4]]
b=[[1,2],[3,4]]
c=list(2*[2*[0]])
for i in range(2):
for j in range(2):
c[i][j]=a[i][j]+b[i][j]
print(c)
Why doesn't this work? It's python btw.
>>
>>54014002
>2*[2*[0]]
not what you think it is

... right?
I don't know this shit but that's the one thing that looks wrong
>>
Rate:

let nat = Seq.initInfinite (fun i -> i)
let rec fizzbuzz sigma =
match ( Seq.nth 0 sigma) with
| n when n%3=0 -> printf"fizz\n"
| n when n%5=0 -> printf"buzz\n"
| n when n%3=0 && n%5=0-> printf"fizzbuzz\n"
| n -> printf"%i\n" n
| _ -> printf"nope\n"
fizzbuzz (Seq.skip 1 sigma)

fizzbuzz nat
>>
>>54014037
fuck

let nat = Seq.initInfinite (fun i -> i)
let rec fizzbuzz sigma =
match ( Seq.nth 0 sigma) with
| n when n%3=0 -> printf"fizz\n"
| n when n%5=0 -> printf"buzz\n"
| n when n%3=0 && n%5=0-> printf"fizzbuzz\n"
| n -> printf"%i\n" n
| _ -> printf"nope\n"
fizzbuzz (Seq.skip 1 sigma)

fizzbuzz nat
>>
>>54014029
thanks for that.
Is there a proper way of creating nested lists though?
>>
>>54013940

>paying for winrar
7zip opens .rar archives though, and just works 100% of the time.

>>54013942

Fair enough. I should probably update my Rust compiler at some point.
>>
File: sigh.jpg (466 KB, 1600x1200) Image search: [Google]
sigh.jpg
466 KB, 1600x1200
>>54013850
I've used C++. It's nice, and I get it. I like structs and operator overloading and all that cool shit. I just want to make a thing, and not worry about keeping track of pointers and header files.
>>
>>54014083
Pointers allow you to make things, anon.
You don't spend any time "worrying" about them when they're the most way to interact with data structures.
>>
>>54014083
>operator overloading
>obfuscating your own code
>>
>>54013850

You know Anon, I like C as much as the next guy, but unless it's a hard requirement to use C89, I'm going to use C11 at every opportunity. Unless you're targeting a z80 or some other old embedded processor that doesn't have a GCC or Clang backend, there isn't really a reason to use C89. All valid C89 code should compile as C11 (unless it uses the gets() function, in which case you should literally kill yourself), so you can't really say there's a problem with legacy code not running.
>>
This is dumb, but would this work as a clumsy ddos:

while (1) system("ping google.com");[\code]

I'm aware it's not portable, but it should work, right? Obviously google wod never go down but it could work on smaller targets
>>
>>54014138

If there isn't a hard requirement, you probably shouldn't use C at all.
>>
>>54014070
If it really is just 0, just use [[0,0],[0,0]]
For anything else (with a pattern for example), list comprehensions are a godsend
>>
>>54014141
>ddos
>>
>>54014160
t. C# user
>>
>>54014180

You're god damned right, you son of a bitch.
>>
>>54014160
this desu
Unless you're doing hardware stuff or aren't comfortable with another language, there isn't really a good reason to use C.
>>
>>54014072
Dude I said BUSINESSES not consumers. Why do you think rarlabs is still a company?
>>
>>54014128
I'd only use it where it was natural and obvious what was happening; like adding vectors, or whatever. 'Cause isn't that the point? It barely obfuscates any more than functions, anyway.

But there's a thread for bitching about languages every day. Does anyone want to make a thing with lua and only lua?
Apparently you're all classically trained professionals, so uni level guys would probs be a better fit.
>>
>>54014141

Ping is a pretty shitty tool for DDoS in general. Go analyze something like LOIC and see how that shit works.

Also, while the Windows ping command defaults to sending 4 packets at the target server, that exact same syntax on Linux would simply invoke the ping command once, because without the -c flag, it's just going to ping it infinite times anyways.

>>54014160

Eh, I sometimes like using C for certain purposes. Namely anything that involves lots of FFI shit. I figure since everything's going to need C linkage anyways, I might as well write it in C.

But yes, for most things, C++ is preferable.
>>
>>54014053
just use map instead of that recursion
>>
>>54014221

Right. Businesses are run by incompetent morons who can't be fucked to use a superior product that costs nothing. Forgot.
>>
>>54010492
lol reading this is kind of cute
it really takes me back because you made a lot of the same mistakes that i used to
>>
>>54014275
C++ is garbage though, as are most similar languages like Java or C#.
>>
>>54014416
We all should just use HASKAL and LISP, that way things would really get done
>>
File: Fridgebike.jpg (166 KB, 1280x529) Image search: [Google]
Fridgebike.jpg
166 KB, 1280x529
>>54014416

And what do you suggest we use?
>>
>>54014466
That''s the problem. There is no good high level compiled language. There is C which is good but a pain to write large projects in, there are good functional languages, good scripting languages etc. I'm not even sure what to call this class of languages. high-level imperative languages?
>>
>>54014511
>There is no good high level compiled language
>>
>>54014511

Which class of languages, the C-likes?
>>
>>54014534
C++, C#, Java. OO languages I suppose?
>>
>>54014466
>>54014511
I've seen people suggest writing in Python, then, if extra performance is needed, profiling your code to find the slowest bits, re-writing them in C, then incorporating them into your original Python code using Cython (or a similar alternative).

This method makes sense to me, but I've always been too lazy to try it out.
>>
>>54014576
Python is bad for large projects.
>>
>>54014561

C, C++, C#, Java, JavaScript, and Objective-C can all be classified as "C-like languages", due to sharing a similar syntax.

All of them but JavaScript are compiled ahead of time.
All of them but C are object oriented.

>>54014576

Writing FFI code to talk between scripting languages and C or C++ isn't exactly pretty.

Python of all languages probably isn't best for large programs. 20x slowdown over native code isn't exactly something you can just fine tune around. Plus, it's got one big glaring flaw in the form of a global interpreter lock that's going to keep it from getting any decent performance gains as CPUs improve. We're not able to push clock rates faster, we can barely push RAM speeds any faster (and RAM access times really can be a huge bottleneck for performance). The fastest programs will be those that can take advantage of multiple cores, and those that can best make use of the cache.
>>
>>54014511
c++ is close enough. Performance is there and the syntax isn't completely batshit. It's the perfect (the least shit) language in my mind (COMPARED TO ALL THE REST).
>>
>>54014583
[citation needed]
>>
>>54014801
>implying it isn't common knowledge
>>
>>54014798
I agree with this but that doesn't mean C++ isn't a garbage language, it's just the best available.
>>
>>54013966
looks correct to me, where it is crashing?
>>
File: 1377747757.jpg (17 KB, 550x550) Image search: [Google]
1377747757.jpg
17 KB, 550x550
I get an error on 33-34 that reads "cannot convert from T to LinkedBinaryTree<T>" and an error on line 41 that reads "The Method addRoot(T) in the type LinkedBinaryTree<T> is not applicable for arguments (char)" and another error on line 42 that reads " The method push(T) in the type LinkedBinaryTree<T. is not applicable for the arguments (LinkedBinaryTree<T>)"
My professors pseudo code is :
 
for i = 0 to n-1 do
if ei is a variable or an operator then
T=a new empty binary tree
T.addRoot(ei)
S.push(T)
else if ei=’(‘ then
Continue looping
else {ei == )}
T2=S.pop ()
T=S.pop ()
T1=S.pop ()
T.attach(T.root (), T1, T2)
S.push (T)
end if
end for
return S.pop ()


and my code is:
        tree = new LinkedBinaryTree<T> ();
stack = new LinkedStack <T> ();

for(int i=0; i < exp.length();i++)
{
LinkedBinaryTree<T>T1=null;
LinkedBinaryTree<T>T2=null;
LinkedStack<T> S;
LinkedBinaryTree<T> T ;


char e = exp.charAt(i);

if (e==')') {
T2 = S.pop();
T = S.pop();
T1 = S.pop();
T.attach(T.root(), T1, T2);

}
else if (e!='(') {
T = new LinkedBinaryTree<>();
T.addRoot(e);
S.push(T);

}
}

My code is obviously incomplete because of these errors, thanks to anyone who responds!
>>
>>54014850
what language is that
>>
>>54014909
Java, it's a data structures class.
>>
>>54011254
This, but unironically
>>
>>54014912
What are you trying to say with your second clause there?
>>
>>54012626
I agree with you 2bh famillia

Why is web development such a fucking mess?
>>
>>54015073
It's full of know-nothings who wanted easy money working on computers all day
>>
>>54015062
if e is not '(' create a new binary tree give e root and push t
>>
>>54015135
I was referring to the post that I quoted
>>
>>54014268
>I'd only use it where it was natural and obvious what was happening; like adding vectors, or whatever. 'Cause isn't that the point?
Ask iostream.
>>
Which one is "better" for string concatenation in Python?

string_a = "kek"
string_b = "lol"
string_c = "\n"

first = a + b + c
second = "".join((string_a, string_b, string_c))


Apparently the str.join method is faster, but is it really worth it in this case when you have to pass it a tuple/list with just 3 elements?
>>
So what's a good resource to learn modern OCaml?
>>
A minimalist microkernel called GNU/Turd for ARM 64 bit
>>
>>54015135
The class I am taking is Data structures.
>>
>>54015169
char *third = (char *) malloc(sizeof(char) * (strlen(string_a) + strlen(string_b) + strlen(string_c) + 1);
sprintf(third, "%s%s%s", string_a, string_b, string_c);
>>
>>54015173
flips pizza
>>
>>54015198
the only correct answer
>>
>>54015274
But to what question? "How strong is your autism?"
>>
>>54015198
>sizeof(char)
>(char *)
>>
>>54015574
yes?
you're making a pointer to a char array.
>>
>>54015599
>sizeof(char)
It's guaranteed to be 1. It serves absolutely no purpose.
>(char *)
C automatically converts void *s to other pointers, making this completely useless as well. It also violates the DRY principle.
>>
>>54012491
You're a dumbass, btw
>>
What GUI library to go for if Qt isn't an option? QtCreator is slow as fuck on my Pentium 4.
>>
>>54015802
wx
>>
>>54012477
It doesn't even really matter then because your serialisation and deserialisation library should handle it for you. Only time it really matters is when

1. You're writing such a library yourself
2. You're passing around raw bytes for some reason (presumably because you're allergic to using libraries that are out there).

>>54013582
In general ‘Show’ is not intended for this kind of use and you should use a pretty-printing class instead. But what I was actually going to say is that you should just call your tree a tree, that it's printable is just one of its many properties. Only times really you'd call your data types in this fashion is if you're newtyping something specifically to give it some specific instance you need.

>>54015169
You need to state criteria for measuring how good a concatenation is, it's unclear what you mean by ‘better’.

>>54015802
gtk/wx/whatever is OK but consider upgrading your work machine
>>
>>54015802
http://webserver2.tecgraf.puc-rio.br/iup/
>>
>>54015802
>Pentium 4
well it's time to use either win32 or winforms
>>
>>54014128
wew lad you better stay away from haskell
>>
>>54015802
gtkmm
>>
File: sqlite-logo.png (85 KB, 1024x485) Image search: [Google]
sqlite-logo.png
85 KB, 1024x485
how do I select everything in an sqlite query?

this is normal sqlite search for rows that contain word fucktard

SELECT * FROM fucking_table WHERE path LIKE "fucktard"


this would be an option for me but its not good enough

SELECT * FROM fucking_table


I later want to implement NOT, that means show me all rows, except ones containing the specific string

I imagined that this would have work, but it does not, to find all and then later add that NOT

SELECT * FROM fucking_table WHERE path LIKE "*"
>>
>>54016083
People really exaggerate the use of operators in Haskell. There are libraries heavy with them but it's not like you have to use it (and if you use the library you probably know them anyway).

In the 660 line module of real code I have open there is
<|> <$> >>= $ . ++ >>>
, all of which in base and very commonly used.
>>
>>54016101
Not sure what you want to do but something like
SELECT * FROM fucking_table WHERE 1

Would work.
>>
>>54015802
all C/C++ gui toolkits are archaic garbage, use electron or .NET
>>
trait Matcher<T> {
fn is_match(&self, other: &T) -> bool;
}

impl<T, F> Matcher<T> for F where F: FnOnce(&T) -> bool {
fn is_match(&self, other: &T) -> bool { self(other) }
}

impl<T: Eq> Matcher<T> for T {
fn is_match(&self, other: &T) -> bool { *self == *other }
}


The compiler is telling me these two implementations are conflicting. Anyone know what's causing it?
>>
>>54016111
thnx it works but I had some problem coupling it with the NOT statement...
it works now it seems
>>
>>54016234
I don't know C++ but my guess is because you're providing an instance for any generic ‘F’ while also providing an instance of ‘Eq’: it can't know if it should use Eq or F implementation.

But that's just a guess, I know nothing about the semantics here.
>>
>>54016234
>>54016326
Well, actually I don't even think that's C++ which shows how much I know. Either way my guess still stands.
>>
>>54016338
yea it's Rust
>>
What's a good hashing function to use in my game?
I've never used any hashing functions before, but it should satisfy these requirements: Fast and output a 32bit integer.
>>
>>54016378
strlen()
>>
>>54016378
What exactly do you want to achieve?
>>
>>54016378
md5 is fast af, so use that and just truncate into 32bit
>>
>>54016387
Rasmus please go.
>>
>>54016408
>truncate

stop this AAAAAAAAAAA
>>
es6 is lit
const id = x => x;
const add = (a, b) => a + b;
const equals = (a, b) => a === b;
const liftM2 = (f, A, B) => A.flatMap(a => B.map(b => f(a, b)));
const addM = (a, b) => liftM2(add, a, b);
const equalsM = (a, b) => liftM2(equals, a, b);
const join = (a) => a.flatMap(id);

assert(equalsM(addM(Just(1), Just(2)), Just(3)));
>>
>>54016461
gud shit
>>
>>54016461
>JUST
>>
>>54016378
memecrypt str = str.map(ord).reduce(0, _ + _)
>>
>>54015802
WIth a Pentium 4, compiling is going to be slow no matter what toolkit you use.
>>
>>54016326
F is constrained to being a function, though.
>>
What are the best map api's out there?
>>
File: 1460544846.png (46 KB, 780x507) Image search: [Google]
1460544846.png
46 KB, 780x507
python
iterate over list and remove elements if they fit some condition

why do I read all over the internet to make copy of the list, that its not possible
and shit like that?

here, it works and seems fine

I know that indexes might get moved when you suddenly pop one, but there dont seem to be any problems

so whats up? is it just good practice?
>>
>>54016829
>iterate over list and remove elements if they fit some condition

that's just filter, it's even built-in already

>why do I read all over the internet to make copy of the list, that its not possible
and shit like that?

????
>>
>>54016849
http://stackoverflow.com/questions/10665591/how-to-remove-list-elements-in-a-for-loop-in-python

>You are not permitted to remove elements from the list while iterating over it using a for loop.
>>
>>54016829
Try printing the list with each iteration and see what happens. Also:
new = filter(lambda x: x in ['b', 'd'], list)
>>
>>54016829
filter = ['b', 'd']
...
if x in filter:
new.append(x)
list_.remove(x)

fixed it a bit for you
>>
>>54016829
nigga just use filter()
>>
>>54016865
great, now I have some fucked up filter object instead of nice understandable list
>>
>>54016889
new = list(filter(lambda x: x in ['b', 'd'], list))
>>
>>54016889
Also don't use the "list" as your variable name.
>>
>>54016916
I dont
I use list_
and only for example so that shit is easy to understand with just half second cursory glance that happens on /g/
>>
File: 1460546080.png (58 KB, 1053x542) Image search: [Google]
1460546080.png
58 KB, 1053x542
>>54016901
>>54016874
I need both, the list without the items and the items find

any way to do it in the single loop of the lambda function?
with for I would do it..
Thread replies: 255
Thread images: 20

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.