[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: 35
File: parallelconcurrenthaskell.jpg (795 KB, 2100x2756) Image search: [Google]
parallelconcurrenthaskell.jpg
795 KB, 2100x2756
Haskell is the future edition

>Object-oriented programming is eliminated entirely from the introductory curriculum, because it is both anti-modular and anti-parallel by its very nature.
-CMU professor, upon realizing OOP is unsuitable for modern computer science

https://existentialtype.wordpress.com/2011/03/15/teaching-fp-to-freshmen/

Old thread: >>54809718 (but who cares? we're looking at the future now!)

How will Pajeet manage in a post-Java world? I don't know, but myself, I can hardly wait for it.

http://learnyouahaskell.com/chapters

http://book.realworldhaskell.org/read/

http://chimera.labs.oreilly.com/books/1230000000929/index.html

Training wheels: https://docs.python.org/3/howto/functional.html (note that this is not even nearly as good as using a proper functional language like Haskell)
>>
Why the fuck do I need math for programming?
>>
encapsulation is good for necessary state
>>
>>54818438
You don't as long as you're happy being a code monkey
>>
ok so working on nis. i have set my install to main server, but i see in the vids that people setup another host when they do this. so should i setup another host to handle client server interaction or will it be ok with my install being the master server?
>>
>>54818406
5th for Go
>>
>>54818476
I don't get the need for all the books on performance. Just add a simple caching layer and you are good 95% of the time.
>>
>>54818438
if you're no good at math, you think you don't need it because you don't know what you're missing and how crippled you are

if you know math well, you can recognize the situations where you need to use specific math knowledge to come up with an elegant solution for a particular problem
>>
>>54818498
shig
>>
>>54818498
kys
>>
What languages does android natively run. Is there a way I can compile java code to run on an android console?
>>
>>54818615
C
>>
>>54818615
>What languages does android natively run
android has different java VMs, so it can run ARM code and java bytecode.
>>
>tfw code monkeys try to convince me prolog is useless
>>
>>54818803
what are you using prolog for
>>
>>54818819
I signed an NDA. That's why that question is so annoying.
>>
>>54818469
Control of effects through linearity, monads, etc. is better. Encapsulation to prevent the user meddling and leading to "invalid state" is BTFO by dependent types.

It's only useful for hiding implementation details and maintaining an ABI. In that case, just use PIMPL or a closure, you don't need a special public/private/whatever language feature.
>>
>>54818849
so maybe it's useful for some le sekrit club stuff but it's probably not useful for general-purpose programming
>>
>>54818876
http://talk.maemo.org/showpost.php?p=1047008&postcount=1655
>>
>>54818932
>nokia
lol
>>
>>54818963
>your opinion
lol
>>
>>54818678
>java bytecode
are those not class files?
>>
kys sperg every language except c and java is a meme and only used by retarded trap fags
>>
File: sicp anime girl 3.jpg (100 KB, 600x338) Image search: [Google]
sicp anime girl 3.jpg
100 KB, 600x338
>>54819210
>>
>>54819278
Was it a good impression?
>>
>>54818438
You don't. You need very very limited math. And if you need math it's because it's domain specific (if you're doing graphics you'd need the graphics related math).
>>
>>54819210
>every language except c is a meme
Fix'd.
>>
File: 3610155510612_600.jpg (41 KB, 600x600) Image search: [Google]
3610155510612_600.jpg
41 KB, 600x600
>>54819210
>kys sperg
>java

:^)
>>
File: wow anon.jpg (78 KB, 884x574) Image search: [Google]
wow anon.jpg
78 KB, 884x574
>>54818406
>is eliminated entirely from the introductory curriculum
>entirely

https://www.csd.cs.cmu.edu/academics/undergraduate/requirements
>**Students with no prior programming experience take 15-112: Fundamentals of Programming before 15-122.

https://www.cs.cmu.edu/~112/schedule.html
>Week #9 Object-Oriented Programming (OOP) (part 1)
>Week #11 Object-Oriented Programming (OOP) (part 2)

lel, debunked dat shit.
>>
>>54819210
it's C++ and java, C is mostly irrelevant in this day and age, Ctards only like it because they're too stupid to understand OOP and use features that transcend fizzbuzz-tier babby programs
>>
>>54819716
>what is embedded development
>>
>>54819210
I'm learning assembly and I bet I'll someday be better than you could ever be with your Java shit.
>>
>>54819716
You know, you can understand OOP and dislike it. Actually, I'd say liking OOP stems from a misunderstanding of how useless and harmful it is as a paradigm.
>>
File: [tilting increases].png (27 KB, 500x500) Image search: [Google]
[tilting increases].png
27 KB, 500x500
>>54819730
>>
Question for those of you still studying: who do you bitch to about your grades when all your friends have worse ones that you do? I feel like every time I complain they just think I'm a prick because I had much more than them, but I need to talk about it to someone.
>>
>>54819800
Bitch to /dpt/, but show us your tits first you pathetic little girl.
>>
>>54819800
Just smoke a joint man

No one cares about grades anyway
>>
File: prewrfs.png (11 KB, 721x391) Image search: [Google]
prewrfs.png
11 KB, 721x391
>>54819730

What's your favorite paradigm?
>>
>>54819851
Procedural and pure functional. Imperative can be modeled in pure functional using linearity/monads.
>>
>>54819837
>>54819838
I care about my grades to an unhealthy point. I didn't choose to be like this and I can't just turn it off.
>>
>>54819872
>Procedural and pure functional.

How did I know this would be your response? How did I know?
>>
>>54819889
What's your point?
>>
File: le poo calling.jpg (51 KB, 512x288) Image search: [Google]
le poo calling.jpg
51 KB, 512x288
>>54818438
>>
C++

std::vector<Point> points_list;
// ...

bool matrix = new bool[number_of_points];

for (size_t i = 0; i < points_list.size(); i++) {
if ( is_point_in_list(points_list[i], global_list) ) {
matrix[i] = true;
}
}




gives this error
 error: invalid types ‘bool[int]’ for array subscript


i can't use int because points_list.size() is a size_t


what do?
>>
>>54819903
>OSGTP
>expecting an argument
I'm sorry for you.
>>
>>54819954
cast to int or use a better language
>>
I'm trying to find a talk that was from some old guy at MIT (I think) where he basically gives a rundown of what computer science is, has been and should be and how the current aims in academia are far to short sighted.

I remember it being a very nice talk/lecture with tons of good ideas but I can't remember who it was.
>>
>>54819903

Functional and procedural fags are utterly full of themselves and hopelessly delusional.
>>
>>54819954
use size_t, you dumbass
>>
>>54819954
>assigning an array to a bool variable
>>
>>54819954
>bool matrix = new bool[];
That shouldn't compile.
>>
File: nope, no argument in this pipe.jpg (20 KB, 720x533) Image search: [Google]
nope, no argument in this pipe.jpg
20 KB, 720x533
>>54819975
>>
>>54820004
>posting steban bobydeux

Not an argument
>>
>matrix translation values are M[3][0],M[3][1],M[3][2]
>not M[0][3],M[1][3],M[2][3]

Fucking why do people do this?
>>
I've never programmed before (besides some light bash and python scripting) and I'm going to try and force myself into Haskell.

Wish me luck, and I hope I don't hit a brick wall.
>>
>>54820022
It's an old af convention
>>
>>54819975
this
>>
>>54820018
Not him but I really like the Steban meme. Less pointless discussion where opinions pose as arguments.
>>
>>54819982
>use size_t, you dumbass
what part of
 error: invalid types ‘bool[int]’ for array subscript 

you don't understand?
>>54819986
>That shouldn't compile.
you wot
>>54819985
>assigning an array to a bool variable

what
>>
>>54820028
Good luck anon.
What's your plan of attack btw?
>>
>>54820046
bool[] matrix = new bool[number_of_points];

new bool[] returns an array, not a bool.
>>
>>54820028
you're just another brick in the wall.
>>
>>54820022
row major is best major
>>
>>54820046
new bool[number_of_points];

Returns a bool*.
You're declaring a bool.
Yet you're saying "error: invalid types ‘bool[int]’ for array subscript". As if the type mismatch wasn't an issue.
Fix that first.
>>
>>54819954
Use:

bool *matrix = new bool[number_of_points];


or

bool matrix[number_of_points];


or

std::vector<bool> matrix(number_of_points);
>>
File: row-major-3D.png (26 KB, 799x390) Image search: [Google]
row-major-3D.png
26 KB, 799x390
>>
>>54820044
>Not him but I really like the Steban meme.

I've come to like it, too, actually. It made me realize that very few statements are really arguments.
>>
https://youtu.be/qlnU73a3Cw0
>>
>>54820082
>>54820091
yeah my bad it should be
 bool *matrix 


what about the other error?
>>
File: teddy dance.gif (550 KB, 163x153) Image search: [Google]
teddy dance.gif
550 KB, 163x153
>>54819954
Instead of trying to use an array of bools, why don't you use an int array with 1s and 0s instead?
It might be a bit more code, but it's less likely you'll fuck that up.
>>
>>54820117
Well.. You can index your array now.
bool*[int] is ok.
>>
File: row-col.jpg (44 KB, 301x142) Image search: [Google]
row-col.jpg
44 KB, 301x142
if you have a translation vector at mno why wouldn't you store it contiguously in memory
>>
>>54819722
c++, java, even python now
>>
If Haskell is so good, why do Haskell programmers use git instead of something written in Haskell?
>>
>>54820194
Your question is retarded. Please go be retarded somewhere else.
>>
>>54820209
indeed, haskell is not good
>>
>>54820118
He should be using an int for every 32 slots in the array. Just
unsigned int* boolReplacement=new unsigned int[(numberofBools/33)+1];
for(int i=0;i<numberOfBools){ //sets all the bools to 1 one by one
//Just so you get the idea..
boolReplacement[i/32]=boolReplacement[i/32]&(1<<i%32);
}

There. 1 bit per bool. Easy to address into and fits your cachelines way easier than an array of bools.

I may have done some errors here because i'm tired but I think you get it.
>>
>>54820216
I have no experience with Haskell, nor do I give a shit about Haskell, but your question is still retarded. You're fishing for an argument which makes you part of the problem of these threads.

So again:
>>>/b/
>>
>>54820225
Should have used sizeof and not assumed int is 4 bytes. Also missed the i++. Clumsy me.
>>
>>54820194
If Python is so good, why do Python programmers use libraries written in C?

If Python is so good for prototyping, why do Python programmers go out of their way to use 3rd party libraries, rather than writing stuff themselves?
>>
>>54820118
because bool is 1 byte and int 4 bytes. so , less memory consumption

>>54820225

i don't want to optimize that bad. thanks tho
>>
does gcc 5+ default to c99? since when?
>>
>>54820272
You can store 32 bools in 1 int
>>
>>54820259
These are good questions. The only thing I use python for is scripting because I'm on windows frequently and batch sucks ass.

>>54820272
Seems a bit arbitrary to just be 4x as good when you could be 32x as good.
But whatever. Do what you like. It's not like the performance of this code matters right? Nobody would write it like that if they cared lol.
>>
>>54820259
>If Python is so good for prototyping
>why do Python programmers go out of their way to use 3rd party libraries, rather than writing stuff themselves?
because that's exactly what makes it so good for prototyping
>>
>>54820317
>Seems a bit arbitrary to just be 4x as good when you could be 32x as good.
>But whatever. Do what you like. It's not like the performance of this code matters right? Nobody would write it like that if they cared lol.

yeah it doesn't matter. it's just a simple graph problem
>>
>>54820109
thanks
>>
>>54820341
>it's good because someone's already done the work for me, fuck optimising or coming up with solutions better suited to _my_ code
This is why everyone hates Python kids.
>>
File: 1461600827397.png (761 KB, 526x904) Image search: [Google]
1461600827397.png
761 KB, 526x904
>>54820293
>>
>>54820389
 self.kill = True 
>>
>>54820293
>You can store 32 bools in 1 int

>you can store 1 byte in 1 bit
>>
>>54820044
>>54820115
It's made me come to realize that arguments do not actually exist
>>
>>54820430
a bool only stores 1 bit of information
>>
>>54818406
>He fell for the functional programming meme

There doesn't exist an optimal programming methodology for all problems, Boris. OOP won't die off.
>>
>>54820447

wat
>>
>>54820400
>the operator . is not defined
>>
>>54820442
Well. That's the Stephan 'philosophy'.
Disagreements exist. Arguments are just a sophist word for disagreement.
Given perfect information we'd have all the answers through philosophy. But we don't have that.

Stephan is rather dishonest in all this because he's making major leaps just like everyone else. Except he's taking smaller leaps than most.
>>
>>54820498
>Given perfect information we'd have all the answers through philosophy.
1) Not necessarily
2) Wouldn't perfect information already include the answers?

3) Pretty poor philosophy on your part.
>>
>>54820498
I mean, I was having a giggle, but we could roll with that too
>>
>>54820510
Not an argument.
>>
>>54820477
He's incorrect. It stores either 4 or 5 bytes for "True" or "False".
>>
>>54820477
1 or 0, true or false is 1 bit of information
>>
is it bit field or bitfield? fooBitField or fooBitfield?
>>
>>54820510
>not necessarily
You're saying there's two equivalent (qualitatively) answers to a question? I doubt that but yeah I suppose it could potentially be the case. But then there's no reason to argue still because there's no preference to have.
>Wouldn't perfect information already include the answers?
Well yeah, that's by inference though.
>poor philosophy on your part.
Yeah maybe. I don't quite see what your complaint is but sure. I don't feel that confident right now. I'm quitting some SSRI's so I'm not in the most lucid state. I try my best.
>>
>>54820570
No, I'm saying perfect information doesn't necessarily imply "all the answers". There might be answers you want that don't exist or can't exist, for instance subjective matters
>>
>>54820529
He's talking about information. A bool is by definition a two state thing. That's one bit of information.

If you want to represent 256 different information states you can use a byte. It's pretty simple stuff. He's not making himself perfectly clear just to cause an argument (i think).
>>
>>54820570
>You're saying there's two equivalent (qualitatively) answers to a question?

There might be. What would preclude the possibility?
>>
>>54820225
>>54820118
>weak typing
>premature optimisation
Absolutely fucking disgusting. Consider suicide. Use a non-retarded language and let the compiler take care of such trivialities.

>inb4 it can't
STFU and watch.

declare
type Packed_Matrix is array (1 .. Number_Of_Points) of Boolean;
pragma Pack (Packed_Matrix);
Matrix : Packed_Matrix := (others => False);
begin
for Index in Matrix'First .. Matrix'Last loop
if Is_Point_In_List (Points_List (Index), Global_List) then
Matrix (Index) := True;
end if;
end loop;
end;
>>
>>54818406
>Haskell is the future edition

Non-strictness kills it. Very nice in theory, a big headache in practice. Makes reasoning about time complexity difficult and space complexity impossible.

Also lacks a proper module system.

We need a strict pure functional programming language. O better yet, one with a polarized type system.
>>
>>54820689
Haskell isn't even dependently typed
>>
/g/ can't even average 2 ints in C
>>
>>54820596
>subjective matters
Well there's no such thing.
An answer requires a question to be an answer.
If we ask ourselves "what's the best X?". We either make an interpretation that what's meant is the best X for all cases. or we accept that the 'question' isn't specific enough to have an answer, thus not being a question. Subjective matters is just disagreements on what you value. You place your opinion about something ahead of someone elses. If all that matters in this subjective thing is your opinion then there's a clear answer. Any time you have a genuine disagreement you have a difference of values/goals presuming perfect information. Now it may also realistically be the case that the other person (or you) is less informed and can't see the right answer because of it. But there is a correct answer given a set of goals to achieve.
>>54820621
Well I can't say it's likely. But imagine if we had a traintrack, they split off in two directions and later merge. Both tracks are the same length. Both go through the same place in space (suspend your disbelief for a bit here). They're identical options except one goes left and the other goes right. Even then, when where have these decisions with almost no difference between the two choices. They're still somehow different. If I value my opinion, I'm (for arbitrary reasons) more interested in going right than left. I much prefer right. So if I'm driving the train going right would be the better choice if nobody else cares simply because I enjoy going right more (ignoring how this might influence me and have future consequence).

It's just an infinitesimal thing. In real scenarios we wouldn't care to distinguish between the two at some point. But they're never _really_ equivalent unless they're identical.
Yes, incredibly petty.
>>
>>54820727
It's impossible unless we rethink the entire structure of computers
>>
>>54820732
>>subjective matters
>Well there's no such thing
Are you retarded?
>>
>>54820761
>didn't read the rest
I'm explaining why right there.

I'm not saying it's wrong to disagree or fight for yourself. I'm saying it'd be wrong to label something 'subjective' in this context.
>>
>>54820775
>subjective matters is just disagreements
Disagreements don't exist?
>>
>>54820727
int average = low + ((high - low) / 2);
>>
>>54820684
>premature optimisation
Thrown around a lot.

You mean packing your data efficiently would somehow be premature optimization? Sure. If he's unsure that he's gonna need to have bools for this yeah. It'd be pointless to try and make it tightly packed. But my opinion is that if I was in a more lucid state I'd not consider it enough of a hassle to write that code like that.


>let the compiler do it
Honestly dude. Never seen my C++ compiler do something that smart. It's not allowed to as I understand it.
>>54820732
>But they're never _really_ equivalent unless they're identical.
Well I'm really messing up now.. Point was that eventually we'd stop distinguishing between the different answers because they're too similar. But in the limit they're the same.
>>
>>54820798
Anon I know you're just having fun here but can you have your fun without replying to me?
I'm not gonna repeat myself.
>>
>>54820821
Underflow
>>
>>54820821
Loss of precision
>>
>>54820684

Ada is cool.
>>
>>54820871
>using ada in current year
>not using idris or F*
>>
>>54820887

I'm not cool enough to be using primarily functional languages.
>>
>>54820908
N E R D
>>
>>54820821
Overflows when
high - low > MAX_INT
>>
>>54820871
it's shit.
>>
Is OpenMP the best runtime library to write multi-threaded applications in C?
>>
>>54820926

I didn't mind using it. Trying to do what I wanted with unbounded strings was a little tough, though.
>>
> tfw read createinterface as creatine face.
Man, I need to get my caffeine habit in order.
>>
File: 1355592808571.jpg (113 KB, 500x500) Image search: [Google]
1355592808571.jpg
113 KB, 500x500
Can I make android apps in C?
>>
>>54821017
Hypothetically yes.
Realistically you'd probably be better off going with the NDK
>>
>>54821017
yes

https://developer.android.com/ndk/samples/sample_hellojni.html

enjoy
>>
>>54821032
wrong link

https://developer.android.com/ndk/samples/sample_na.html
>>
>>54821017
You can make anything in any language
>>
>>54820961
You can also write your own M:N threading library with ucontext and pthreads, which can actually perform really well.
If you have no problems with the annotations in the C then just use OpenMP.
>>
>>54818406
people who use c over c++ because of its 'simplicity' and then promptly use hand-made linked list structures for things where an std::vector would be more appropriate because reallocing the pointer is too much hassle are trying too hard
>>
>>54821125
Cry about it
>>
>>54821125
>implying STL is good
>>
>>54821141
keep making things harder for yourself and writing unoptimized software

>>54821191
why wouldn't it be good?
>>
>>54820727
Do I win?

function Average (X, Y : in Integer) return Integer is
-- if you wanted to get a Float back you should've said so earlier
begin
if (X > 0 and Y > 0) or (X < 0 and Y < 0) then
return Y + (X - Y) / 2;
else
return (X + Y) / 2;
end if;
end Average;

pragma Export (C, Average, "average_2_ints_in_C");
>>
>>54821202
Because they make a lot of helper classes.
For example, deleting a node from a linked list is O(n) instead of O(1)
>>
File: Screenshot_2016-05-30_13-13-15.png (229 KB, 401x627) Image search: [Google]
Screenshot_2016-05-30_13-13-15.png
229 KB, 401x627
>>54821202
>implying I use C for all my projects and not only as needed
Keep crying about it

And thanks moot
>>
>>54820727
int average(int num1, int num2, char *err){
long tmpLong;
*err = 0;
tmpLong = num1 + num2;
if(tmpLong & 1 == 1) *err |= 1;//first bit in err is loss of precision
return (int)(tmpLong/2);
}
>>
>>54821049
in most langs, you'd just have to write compiler support for ARM, graphics libraries, system libraries and so on
>>
>>54821238
>as needed
for what? kernel/driver development?
>>
>>54820448
OOP isn't the optimal methodology for anything and I have yet to be shown otherwise.
>>
>>54821204
what if x+y is > System.Max_Int?
>>
>>54821280
i know right
all strings should be lists of integers
>>
>reallocing the pointer is too much hassle
It's easy as fuck though. push_back, pop_back, erase, etc can all be reimplemented easily with realloc, memmove and memcpy.
>>
>>54821295
What the fuck does that have to do with OOP?
>>
>>54821278
Mostly low-level shit, yesh
Also good to know since I'm going into security
>>
>>54821292
>what if x+y is > System.Max_Int?
Then X > 0 and Y > 0 so the calculation will be Y + (X - Y) / 2 as shown, thus avoiding the overflow.
>>
>>54820057
Currently I'm watching a few introductory videos, as well as http://learnyouahaskell.com/starting-out
>>
>>54821312
i thought you were a functionalbro

>>54821313
>going into security
that's great
i still think that it's much easier to shoot yourself in the foot with manual memory management instead of stl stuff
but if it's really low level you i guess you have no choice
>>
>>54821377
I didn't say about functional programming. Functional programming is not what you get when you take away OOP.
>>
>>54820727
>>54820746
>>54820821
>>54821204
>>54821259

All that work for a freaking average. C is hopeless.

Unless you are writing a very, very optimized piece of graphics or crypto code use a language with actual integers, or at least one that panics on overflow instead of silently wraparound or, God help me, fucking undefined like C.
>>
File: OOP1426869910027.png (152 KB, 1948x858) Image search: [Google]
OOP1426869910027.png
152 KB, 1948x858
Is the right pic as bad as it seems?
>>
>>54821388
of course
you get pascal
>>
>int (*average)(int,int)
Already wrong.
>>
>>54821409
You get whatever you started with, without OOP.
>>
>>54821390
No, it's worse
>>
>>54821390
Even the left pic is bad.
>making a new class just to change the values of some fields
That's what objects are for.
>>
>>54821368
it's not as hard to learn as it seems first i think
you just need to realize that functions in haskell are not like functions in python at all, everything centers around the return value and you make transformations on the input to get the return you want
monads are really easy as well - for example: the maybe monad goes through a few
>>
>>54821389
Eh. Ada has actual Integers and will throw a Constraint_Error if you overflow an Integer calculation. It'll wrap around if you're working with a modulo type, but that should be bloody obvious.
>>
>>54821389
>All that work for a freaking average. C is hopeless.
It's moreso people nitpicking hard about the responses people give, it's not like C is the only language that would have trouble with this
>>
>>54821454
You can't write non-terminating programs in Ada, right?

How could you get user input?
>>
>>54821368
functions which you write and early returns when any of those return None
useless :: Maybe Int
useless = None

other :: Maybe Int
other = do
useless
return 0


also the return statement is not a return statement at all
it converts an Int (0) into a <any monad> Int (Maybe Int) so the last statement will have the right type
>>
File: fsharp code quotation.png (3 KB, 278x41) Image search: [Google]
fsharp code quotation.png
3 KB, 278x41
>>54821475
>>
>>54821482
Ada. Not Agda.
>>
>>54821516
/g/ doesn't make any difference
>>
>>54821482
You can have a total language that is Turing complete. Corecursion, which has the requirement of "productivity", not termination, allows you to recover infinite loops, infinite lazy sequences, etc. which can be executed by a runtime.

>>54821516
Ah, that makes sense if he was confusing them. Agda has corecursion, but not a runtime like I described. So you can create infinite things, but only ever "execute" a finite number of "steps". So Agda is not Turing-complete.
>>
>>54821533
But they literally might never terminate
>>
python newbie here


word_list = []
grammar = [1,0,1,1,0,0,1,1,1,0]

for i in range( len(grammar) ):
if grammar[i] == 0:
word_list.append(grammar[i-1])
word_list.append(grammar[i])
if (grammar[i+1] == 1):
word_list.append(grammar[i+1])


basically when a 0 appears in grammar i want to add the previous element and the next element to the word_list (if the next element is 1) if the next is 0 i want to keep adding until a 1 appears.

but it doesn't work for the case
 [1,0,0,1] 


any help?
>>
>>54821541
The runtime can stop evaluating the infinite structure when it wants to terminate.

I suppose you could argue that it's not the language itself that is Turing-complete, but the same argument applies to Haskell when you say that the language can't actually run effects, only the runtime.
>>
>>54821596
How is it well behaved if it can _decide_ to stop running the program in non-exceptional circumstances
>>
File: shot0004.jpg (93 KB, 1280x720) Image search: [Google]
shot0004.jpg
93 KB, 1280x720
>mfw someone claims OOP is dead while it is the only thing keeping huge projects possible
>mfw the Haskell fags still don't understand that languages are tools for non-CS people and their only argument is literally muh monads
>>
File: foods.webm (3 MB, 640x360) Image search: [Google]
foods.webm
3 MB, 640x360
/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA)

>>54821482
You can't write anything in Ada: The programming language died years ago.

>>54821454
>will throw a Constraint_Error if you overflow an Integer calculation
Which is avoidable when averaging 2 integers.

>>54820727
>>54821389
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);
}


>>54820293
An int is not necessary 32 bits.

>>54819723
Sure

>>54818615
Anything compiled to javabyte code is now AOT compiled.
https://en.wikipedia.org/wiki/Android_Runtime

>>54818438
Programming is one of the most difficult branches of applied mathematics; the poorer mathematicians had better remain pure mathematicians.
>>
>>54821625
>int (*average)(const int, const int)

no
>>
>>54821618
Well, obviously you'd want to use a runtime/framework that doesn't do that. Or write it yourself, but do it inside some kind of "unsafe block" which you'd need to have for things like FFI anyways.

And if you want the program itself to be able to tell when to terminate, you can just use a potentially-infinite list instead of an infinite stream, for example.
>>
>>54821503
Does that really deal with overflow?
The solutions is to accumulate the average and deal with rounding.
>>
File: result.png (14 KB, 1204x118) Image search: [Google]
result.png
14 KB, 1204x118
>>54821675
it's bait
>>
>>54821684
It literally evaluates to an AST for the average of 2 integers
It's like if average(5,4) returned "(5+4)/2"
>>
>>54821618
>>54821655
Keep in mind that what I'm saying is pure conjecture and, to my knowledge, has never even been tried. How to recover unbounded loops for useful applications is one of my aims in my language, though.
>>
>>54821564
>>54821564
BUMP

HELP
>>
>>54821655
>>54821715

Surely it is desirable to have a potentially non-terminating but well defined program, but is lambda calculus capable of this?
>>
>>54821620
The biggest program in Haskell is the compiler. Nobody gives a shit about it. It's just a meme on /g/.
>>
>>54821625
>the programming language died years ago
You've never heard of Ada 2012 then? Seems to be doing fine.
>>
>>54821756
And the lack of dependent types.
And the ill defined nature of the language.
And the performance, god the performance.
>>
>>54821756
https://code.facebook.com/posts/745068642270222/fighting-spam-with-haskell/

u said ?
>>
>>54821625
Why do you have to be such a fuckin' faggot? Just off yourself already.

>no bully
Eat dicks, yellow wannabe.
>>
>>54821744
Lambda calculus, yes. It's Turing-complete.

Languages that have provably terminating or productive recurrences? Unsure. I want to explore that, though.

In any case, with our current software ecosystem, you always need to dip out of the language for FFI, short of building everything in. So it's not unreasonable to just stick with termination/productivity and tell people to write things like message loops in "unsafe" fragments.
>>
>>54821777
>browsing facebook
>typing like a retard

You appear to be lost my friend. Reddit is down the hall.
>>
>>54821620
Non sequitur. Anti-OOP and pro-FP are two different things. Also, functional programming is far more than just Haskell, and I've still never seen a solid argument for why we should use OOP over anything else.
>>
>>54819954
You fucking monkey

bool * matrix = new bool[number_of_points];


>what do?
Pay attention in class you subhuman piece of shit.
>>
>>54821812
Turing completeness might not be enough
>>
>>54821852
slowpoke faggot
>>
>>54821564
no idea if this is correct, but...:
>if grammar[i] == 0:
try changing this to
if grammar[i] == 0 and i > 0:
>>
>>54821897
your still a subhuman piece of shit
>>
>>54821873
You asked for a potentially non-terminating but well-defined program. Anything Turing-complete can express this.

Are you asking if there's a way to check for this? I don't know if there is, but there are lots of useful things that we can't yet mechanically verify. It seems like the "good enough" solution is to check what we can (99% of the program) and vastly reduce what the programmer or automated tests have to verify.
>>
>>54821927
Ohh, I was thinking of Total languages
Total languages might not terminate - but Total languages aren't Turing Complete
>>
>>54821916
>your still a subhuman piece of shit
what the fuck pahjeet

get you head out of your ass
>>
>>54821564
>>54821904
also change
>if (grammar[i+1] == 1):
to
>if i < (len(grammar) - 1) and (grammar[i+1] == 1):

I didn't even run your function, but the problem could be this:
>>> a=[0,1,2]
>>> a[-1]
2
>>
>>54821959
Totality is generally taken to consider provably terminating recursion AND provably productive corecursion.

Are those two metrics good enough, even just theoretically? Maybe.
>>
>>54821916
>subhuman piece of shit x2
That's it anon, timeout. No TV or computer games for 2 hours. Think about what you just said.
>>
>>54822014
but MOOOOM!
>>
I would like to make a realtime 3d software renderer as a summer project. On a similar level to something like the one used in Quake, for example.

Are there any resources on doing this that are any good?
>>
>>54821625
>Programming is one of the most difficult branches of applied mathematics; the poorer mathematicians had better remain pure mathematicians.

Do you have any recommendations for improving basic math for programming? I am slightly numerically dyslexic... did basic college math by jumping through hoops like a good little sheep but I honestly feel like I never really learned anything... only how to memorize irrelevant formulas. I have very little understanding of "core" concepts and the overall ideology etc. Any advice.?
>>
>>54822265
practice makes perfect
implement something
>>
How can you practice something you don't have a basis for? This is what I asked... General improvements / base concepts not implementation of something I am already week it.
>>
>>54822348
Google you dumbass
>>
>>54822348
>How can you practice something you don't have a basis for? This is what I asked... General improvements / base concepts not implementation of something I am already week it.

The only thing I have found is the youtube channel numberphile so far.
>>
>>54822368
>Google you dumbass

Google comes up with a lot of non related things you shitcunt. I am looking specifically for programming related logic or WHAT type of base concepts I should look into. Not just googling "maths" and reading everything like an autist.
>>
>>54820689
>We need a strict pure functional programming language.
Just use ML.
>O better yet, one with a polarized type system.
Hell no.

>>54820719
GHC's is.
>>
>>54822394
You're so damn incompetent
>>
File: kissu.webm (3 MB, 1280x720) Image search: [Google]
kissu.webm
3 MB, 1280x720
>>54822265
http://betterexplained.com/articles/developing-your-intuition-for-math/

>>54822265
>>54822229
http://immersivemath.com/ila/index.html

>>54822229
http://www.scratchapixel.com
>>
File: zWrJlCu.png (651 KB, 1024x1023) Image search: [Google]
zWrJlCu.png
651 KB, 1024x1023
>>54822569
>>http://www.scratchapixel.com
Thanks anon.
>>
>>54821564
>>54821564
>>54821564
>>54821564

LAST BUMP

does anyone know how to solve this?
>>
>>54822569
Sauce? That's some fine animation I haven't seen for ages in mainstream animu.
>>
File: megatron-300x205.jpg (20 KB, 300x205) Image search: [Google]
megatron-300x205.jpg
20 KB, 300x205
>>54822719
Monad transformers.
>>
What are the most effective ways in C++ to read parts of a file to an integer without any casts? eg I have a file header that is 4 bytes. How can I read in these 4 bytes to some kind of buffer, then assign the whole to a 32 bit integer? At such a point I can just test for equality rather than reading the bytes one by one, or making some sort of array when all I really care about is the header values match a predefined set of values.
>>
>>54822727
Yeah, I'm sure you want it for the "animation"
>>
>>54822821
Don't worry, YuruYuri and Yuyushit have successfully destroyed my apetite for the genre.
>>
>/g/ says QT is a meme
>check documentation and some features
>it actually seems really good and perfect for what I need
why do you people hate everything
>>
>>54822920
>trusting /g/
>being happy and successful in life
pick one
>>
>>54822569

Thanks, I will check out the developing your intuition.
>>
>>54822801
Lemme check... yeah,
input.read (buf,buflen);
is probably going to be your operation. As for the arguments, you can go for an union with a
char[4]
and an int, pass the array as the buffer to read, and use the int. This only ever works if
sizeof(int) == 4
and in geneeal if there actually is a type with the correct size on your platform though, so I would probably go without an union and with memcmp, but maybe flexibility doesn't appeal to you...
>>
Question:

If I have a list of strings, say [R, B, Y, O, G, B] how can I make some code that will give me a random permutation of this list every time I run it.

I'm using python btw.
>>
>>54823214
Either use your brain or google it. Period. I don't see how such a boring and closed question is of any interest to the general. And if tgat's not the point, then what is your reason for asking? No really what is it?
>>
>>54823214
>make copy of list
>scramble elements randomly
>return list
>google how to grow a brain
>attempt to learn how to read the answers
>>
File: CanvasImage.png (2 MB, 4000x4000) Image search: [Google]
CanvasImage.png
2 MB, 4000x4000
Anyone here done work with automata? Just finished programming a hexagonal grid for a turmite (basically a multi state langtons ant). Tiling is a little bit buggy though.

Here's something I found awhile ago with just a basic multi color ant.
>>
File: five-pointed-star-rainbow.png (278 KB, 1000x1000) Image search: [Google]
five-pointed-star-rainbow.png
278 KB, 1000x1000
I wrote a Python "library" to generate Spirographs. Turns out it's basically one function that does all the work. I need to come up with more ambitious project ideas. Pic related.
>>
>>54823463
I did the basic Langtons ant.
Found something surprising as a bug.
>>
>>54823463
>>54823500
nice senpai
>>
File: Langtons Ant SFML.webm (760 KB, 566x478) Image search: [Google]
Langtons Ant SFML.webm
760 KB, 566x478
>>54823463
>>54823504
I don't remember what the exact cause was. Probably a buffer overrun (IIRC the map is just an array of ints, indexed with X being multiplied by the stride). So when X went negative you end up on the other side of the screen. And I think you're not sampling exactly where the ant was. But in any case it largely went in reverse.
>>
~ cat "$(which vpn-whitelist-domain)"
#!/usr/bin/env python
import sys

from plumbum.cli.application import Application, Flag
from plumbum.cmd import dig, ip, sudo


def get_default_gateway():
for line in ip('route').splitlines():
# Return first default gateway found that isn't a virtual VPN device
if line.startswith('default via') and not 'dev tun' in line:
return line.split('default via')[1].split(None, 1)[0]


class VpnWhitelistDomain(Application):
remove = Flag(['-r', '--remove'])

def main(self, domain):
default_gateway = get_default_gateway()
if not default_gateway:
print('Error: Could not determine default gateway:' % (ip('route')), file=sys.stderr)
print(ip('route'), file=sys.stderr)
return 1

for address in dig(domain, '+short').splitlines():
if self.remove:
sudo(ip['route', 'del', address, 'via', default_gateway], retcode=None)
print('Removed', address, 'from whitelist')
else:
sudo(ip['route', 'del', address, 'via', default_gateway], retcode=None)
sudo(ip['route', 'add', address, 'via', default_gateway, 'proto', 'static'])
print('Added', address, 'to whitelist')


if __name__ == '__main__':
VpnWhitelistDomain.run()


Allows me to quickly set up a way to bypass my configured VPN on Arch Linux (mostly to shitpsot on 4chan, like right now). Meant to post this here.
>>
>>54823648
Are you Eevee or are you just using his plumbum library?
>>
>>54823708
I am just using the library. It has 1200 stars on GitHub, I'm sure I'm not the only one. Why would you think I'm the developer (is that who eevee is?).
>>
>>54823708
>>54823726
I just checked, it's not eevee's library -- you seem to be misinformed.
>>
>the Church numeral encoding of ω (= ω+1) is the Y combinator
YOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
>>
>>54823768
It's on his projects page though, senpai
>>
>>54823842
You are right:

> I added a TEE modifier for both capturing and piping a process’s stdout.

He contributed a feature. But yeah plumbum is pretty neat, and I much prefer it over sh.py (you can't even use sudo with sh.py without it blocking/working around it).
>>
>>54823842
>eevee
>1 commit / 51 ++ / 14 --

the guy who owns it:
>tomerfiliba
>309 commits / 30,283 ++ / 21,667 --
>>
>>54823854
Have you used fabric? I can't remember whether it has the piping features but if it doesn't it would be a pretty neat addition.
>>
>https://en.wikipedia.org/wiki/Haskell_Curry
POO
>>
File: 1.jpg (39 KB, 306x360) Image search: [Google]
1.jpg
39 KB, 306x360
>>54823911
>I'm Tomer Filiba, 28 years old, living in Tel Aviv, Israel.
oy vey
>>
>>54823911
>passing that shit off as his own
You're right though, I should have checked that stuff.
>>
>>54823933
Plumbum actually has SSH/remote support -- Fabric isn't quite aiming to do what Plumbum aims to do, I think.

Plumbum tries to be a shell-like DSL implemented using Python, which makes writing basic shell scripts nearly as easy as using a native shell and more complex scripts infinitely easier and more maintainable.

But I'm not really sure, I've never used fabric to be honest.
>>
How do I learn python as my first language?
>>
>>54824064
docs.python.org/tutorial/
>>
>>54819055
>my dick gently cumming in your mom's pussy
lol
>>
>>54824064
If it's your first language I might recommend http://learnpythonthehardway.org/book/, because it will get you thinking about programming instead of just Python syntax.
>>
>>54818406
I started off with java and just started learning assembly. Thoughts? Is it worth?
>>
>>54824289
Should probably learn something that lets you put that knowledge to use aswell. A language that doesn't JIT would be a start.
>>
When you CROSS JOIN something in SQL, Where is the resulting table stored?
>>
>>54824379
Probably in the answer key for your homework assignment
Thread replies: 255
Thread images: 35

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.