[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: 38
File: 1462904653770.jpg (40 KB, 700x551) Image search: [Google]
1462904653770.jpg
40 KB, 700x551
Old thread >>54539924

What are you working on?
What do you think DAT BOI would be working on?
>>
how long should it take to invert a 256*256 matrix
>>
File: 1462314346858.jpg (11 KB, 200x179) Image search: [Google]
1462314346858.jpg
11 KB, 200x179
>>54545017
>>
>>54545051
About 2-3 hours on modern GPUs
>>
>>54544912
I'm really having trouble grasping that. But what I would like to add is that it has to split on certain points.
An example of what I get would be:

"timer 10 minutes 20 seconds"


This has to split into:

array[0] = timer
array[1] = 10
array[2] = minutes

and so on.

>>54544955
It's a weird form of C++, and copy pasted code doesn't work.


My idea is to for loop through the entire thing, counting the amount of spaces. Then create an array of that size, for loop it again, and substring the string into that array. But that just feels horribly inefficient.
>>
>>54545017
fuck off with this shitty meme
>>
File: Screenshot_2016-04-21-10-13-00.png (903 KB, 1080x1920) Image search: [Google]
Screenshot_2016-04-21-10-13-00.png
903 KB, 1080x1920
You know, people complained about the trap thing being posted.

But this,

This is infinitely worse.
>>
Minimum requirements for a modern programming language:

>dependent types
>higher-kinded types
>typeclasses
>effects/IO
>tail call optimization
>type inference
>trampolining
>>
>>54545084
yourString.split(' ', -1)
>>
>>54545097
is that a dude
>>
>>54545104
JavaScript?
>>
>>54545097
I miss the Norway /dpt/ thread.
>>
>>54545115
split does not exist.
>>
>>54545142
http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#split%28java.lang.String,%20int%29
>>
>>54545142
Use jQuery
>>
>>54545155
>>54545156
I'm writing code for Arduino. I mentioned that on previous board, sorry.
>>
>>54545133
Me too, man, me too.
>>
>>54545133
det gör inte jag
>>
>>54545201
Why not, Swedebro?
>>
File: shit everywhere.jpg (42 KB, 400x502) Image search: [Google]
shit everywhere.jpg
42 KB, 400x502
>>
fuck all scandinavians, southern europe is true europe
>>
hi, i made this C# script for a 2d game, and i got some issue for the walljump, i want it to jump vertically, but he only jump on the y axis for some reasons, i tried to remove the things that makes my character move on the x axis and it worked, but then i couldn't move on the side so yeah.. any advices ?
>>
>>54545268
>southern 'europe'
>moors
>unemployment
>denbts
>catholics
>>
the code from >>54545271


using UnityEngine;
using System.Collections;

public class PlayerControllerScript : MonoBehaviour
{
public Rigidbody2D Body;
public float maxSpeed = 10f;
bool facingRight = true;
public float jumpForce = 700f;
public float walljumpForce = 700f;
Animator anim;

bool walled = false;
bool grounded = false;
public Transform wallCheck;
public Transform groundCheck;
float wallRadius = 0.1f;
float groundRadius = 0.2f;
public LayerMask WhatIsWall;
public LayerMask WhatIsGround;

void Start () {
Body = GetComponent<Rigidbody2D> ();
anim = GetComponent<Animator> ();
}

void FixedUpdate()
{
grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, WhatIsGround);
walled = Physics2D.OverlapCircle (wallCheck.position, wallRadius, WhatIsWall);

anim.SetBool("Ground", grounded);
anim.SetBool ("Wall", walled);

anim.SetFloat ("vSpeed", Body.velocity.y);

float move = Input.GetAxis ("Horizontal");

anim.SetFloat ("Speed", Mathf.Abs (move));

Body.velocity = new Vector2 (move * maxSpeed, Body.velocity.y);

if (move > 0 && !facingRight)
Flip ();
else if(move < 0 && facingRight)
Flip ();
}
void Update ()
{
if (grounded && Input.GetKeyDown (KeyCode.Space)) {
anim.SetBool ("Ground", false);
Body.AddForce (new Vector2 (10, jumpForce), ForceMode2D.Impulse);


}
//x axis doesn't work
if (!grounded && walled && Input.GetKeyDown (KeyCode.Space)) {
Body.AddForce (new Vector2 (77, 77), ForceMode2D.Impulse);
walled = false;
//fuk you x axis
}
}
void Flip ()
{
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1f;
transform.localScale = theScale;
}
}
>>
File: IMG_20160514_192350.jpg (113 KB, 720x718) Image search: [Google]
IMG_20160514_192350.jpg
113 KB, 720x718
Im just shitposting but i hope u like this image
>>
>>54545296
fuck off
>>
>>54545084
Your idea would work. If you didn't want it to be terribly inefficient: instead of substringing just make a char* array and set each index to point to the start of each word. You will have to place a NUL after each word where the spaces start. No copying, more efficient.
>>
File: 1437487432729.jpg (24 KB, 319x283) Image search: [Google]
1437487432729.jpg
24 KB, 319x283
>>54545271
>2d game
>unity
>>
Anyway I can override C stdlib functions in a source file to use safer or more efficient versions of the functions?
>>
>>54544601
int HighLow(int & CardA)
{
int CardB=rand()%13;
if(CardA==12&CardB==0){CardA=CardB; return 1;}
else if(CardA==0&CardB==12){CardA=CardB; return 0;}
else if(CardA<CardB){CardA=CardB; return 1;}
else if(CardA>CardB){CardA=CardB; return 0;}
else{return 2;}
}

int main()
{
int CardA=0;
int guess, answer;
for(int n=0;n<5;n++)
{
std::cout<<"High or Low? (1/0)\n";
std::cout<<"Current Card: "<<CardA<<std::endl;
std::cin>>guess;
answer=HighLow(CardA);
if(guess==answer){std::cout<<"You Win\n";}
else{std::cout<<"You Lose\n";}
std::cout<<"New Card: "<<CardA<<"\n\n";
}

char turdburglar;
std::cin>>turdburglar;
}


Tfw the interviewer calls the cops.
>>
>>54545017
9 decides what I build this weekend
>>
>>54545361
A mattress fort.
>>
>>54545361
A home for refugees.
>>
>>54545361
A wall.
>>
>>54545339
Why are you saying this ?
unity is gud for 2d game
..i think
>>
>>54545361
a sex robot
>>
see >>54545373
click update
see>>54545378

you have to build a meme post generator
>>
I want to make a small game in Android. Any recommendations on an engine? I only need 2D.
>>
>>54545278
>moors
they actually enriched our culture (this was during the time they weren't useless terrorists)

>unemployment
not our fault that the eu juggernaut ruined us

>denbts
see above point

>catholics
best religion
>>
>>54545407
/agdg/ here, use Unity™.
>>
Hey /dpt/, what's the least cpu consuming method of interprocess communication in python?(between different scripts)

>>54545389
We have a winner
>>
>>54545438
>to kill a fly with a rocket launcher
>>
>>54545340
solution 1 - don't include <stdlib.h> and include "yourlib.h" instead

solution 2 - include both, use stdlib functions where you don't need safer/more efficient variants and use the replacements wherever, making sure to have no name conflicts

solution 3 - have both your lib and stdlib and check http://stackoverflow.com/questions/678254/what-should-i-do-if-two-libraries-provide-a-function-with-the-same-name-generati
>>
>>54545488
>Using a rocket launcher that is run by John Riccitiello, the man who unlocked EA's true, Jewish potential.
>>
>>54545407
libgdx
>>
>>54545340
pretty sure you can #UNDEF function names
>>
>>54545264
Post of the month
>>
fuck y'all i want more cats hidden in pictures
>>
>>54545544
that might cause problems if any of the functions he's using relies on the undef'd function though (might not be a problem depending on the order of operations of the preprocessor)
>>
>>54545051
https://en.wikipedia.org/wiki/Computational_complexity_of_mathematical_operations#Matrix_algebra

O(n^2.373), so assuming it's a matrix of something 8 bytes or less it'll be split second
>>
>>54545017
this crap meme is really being forced hard today
>>
>>54545340
>more efficient than C stdlib
The C stdlib should be basically as efficient as it gets, unless your implementation is shit. So, if you still think you can get more performance out of it, you're calling the wrong function prototype, and should rename the function.
>>
>>54545621
>The C stdlib should be basically as efficient as it gets
No. It's poorly coded.
>>
>>54545635
>c stdlib
>poorly coded

The C stdlib is an API which has multiple implementations (with strict rules for how they should be implemented, but I digress). Perhaps the implementation you're using is shit?
>>
>>54545682
glibc is shit.
>>
>>54545315
Almost sounds like he can't use dynamically allocated memory.
>>
>>54545716
Then why not submit a patch to improve it?
>>
thought about getting into cities skylines modding, then decided my mod idea was shit
>>
My (core) language has finite sets. If you have a type Fin(m), its inhabitants are 0..m-1, and they are the basic unit for pattern matching.

Would it be a bad idea to have a subtyping relation on this? I.e. if you have an value of Fin(m), you could directly use it as value of Fin(n) for n > m? It wouldn't be harmful in terms of soundness, just potentially confusing.
>>
File: Capture.jpg (24 KB, 895x79) Image search: [Google]
Capture.jpg
24 KB, 895x79
>tfw incapable of preventing my code becoming a hacked-together clusterfuck

Do I need to read books about program design or just practice and make lots of mistakes and learn from generating awful spaghetti code?
>>
>>54545774
Because the whole methodology suck.
>>
>>54545809
both
>>
File: kidscode.jpg (159 KB, 852x513) Image search: [Google]
kidscode.jpg
159 KB, 852x513
>>54545809
Python is for babies and you are already in a big mess.
Sure you have to learn a lot of things.
>>
>>54545084
Not sure about C++ but in C I'd.

Count the spaces.

Allocate an array of strings but not the strings themselves.

Use strtok to break the string into null separated words.

Set your array to point to each element.
>>
>>54545809
This nice guide is a good base:
http://book.pythontips.com/en/latest/index.html

Don't hope to develop something good with this little guide only!
The best after that is to read current working code on Github!
>>
>>54545856
Oh hey Orb, how's things?
>>
>>54545939
Not bad thanks. 2 weeks of constipation starting to clear today. Hope I don't block the toilet.
>>
>>54545084
int words(char *str){
int count = 1;
for(;*str;str++)
if(*str==' ')
count++;
return count;
}

char **substr(char *str){
char **toks = malloc(sizeof(char *)*words(str)), **pos = toks;

for(char *tok = strtok(str," ");tok;tok=strtok(NULL," ")){
*pos = tok;
pos++;
}

return toks;
}
>>
File: 1400267454068.jpg (53 KB, 784x811) Image search: [Google]
1400267454068.jpg
53 KB, 784x811
>made a program which prints shapes
>can print a triangle and a box
>have to print a star shape
>been trying for 2 hours and it still doesn't work

Who /2 stupid 2 program/ here?
>>
>>54546037
You're a real sinpi.
>>
>get tired of PascalCase
>want to use snake_case
>it's too late to switch

fug
>>
File: 1420484533102.jpg (54 KB, 456x514) Image search: [Google]
1420484533102.jpg
54 KB, 456x514
>he doesn't use Visual Studio
>>
>>54546109
Just use whatever is standard in the language.
>>
>>54546010
Just remember to flush regularly. Mid-shit it necessary. Let the water tickle your hole.
>>
>>54546180
>Winshit
>>
>>54546180
>He wilfully compiles 4gig Hello World applications that are owned by Microsoft in an IDE that takes 7 solid hours to open.
>>
>>54546214
I'll try. It's hard to pause mid shit sometimes though.
>>
File: 1391185904041.png (393 KB, 395x599) Image search: [Google]
1391185904041.png
393 KB, 395x599
>>54545387
Lord have mercy on your soul.

That's like saying that photoshop is good for basic image viewing.
>>
File: star.png (5 KB, 753x669) Image search: [Google]
star.png
5 KB, 753x669
>>54546037
#!/usr/bin/env python

import turtle
import math

def star (length, count, step):
def point (i):
a = i * 2.0 * math.pi / count
return length * math.cos (a), length * math.sin (a)
def goto (i):
p = point (i)
turtle.goto (p)
turtle.penup ()
goto (0)
turtle.pendown ()
j = 0
for i in range (count):
j += step
goto (j)

def main ():
star (300, 5, 2)
turtle.done ()

main ()


That was so hard.
>>
File: 1454889742083.gif (3 MB, 292x402) Image search: [Google]
1454889742083.gif
3 MB, 292x402
>mfw classmates dumber than me are getting internships at facebook and I'm stuck doing QA work for the summer
Why is life so unfair?
>>
>>54546312
It's about who you know, not git and make friends
>>
>>54546312
>internships at facebook
>implying it's a good thing
>>
File: star2.png (2 KB, 355x326) Image search: [Google]
star2.png
2 KB, 355x326
>>54546037
>>54546307
#!/usr/bin/env python

import turtle
import math

def main (length, count, angle):
for i in range (count):
turtle.forward (length)
turtle.left (angle)
turtle.forward (length)
turtle.right (angle - 360 / count)
turtle.hideturtle ()
turtle.done ()

main (100, 7, 160)


But beware, my code is copyrighted.
>>
>>54546448
#
# Copyright 2016 The people of /dpt/
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#!/usr/bin/env python

import turtle
import math

def main (length, count, angle):
for i in range (count):
turtle.forward (length)
turtle.left (angle)
turtle.forward (length)
turtle.right (angle - 360 / count)
turtle.hideturtle ()
turtle.done ()

main (100, 7, 160)
>>
>>54546527
That's thief. I'm reporting you to competent authorities.

They told me to not come here, I should have stay on reddit.
>>
>>54546014
I've read that malloc and start should not be used with Arduino.
>>
>>54545361
a cuckshed
>>
>>54546527
"""
Copyright (c) 2016
The Regents of the University of California. All rights reserved.

This code is derived from software contributed to Berkeley.
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the University of
California, Berkeley and its contributors.
4. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

@(#)shittystar.py 8.1 (Berkeley) 1/4/94
"""
#!/usr/bin/env python

import turtle
import math

def main (length, count, angle):
for i in range (count):
turtle.forward (length)
turtle.left (angle)
turtle.forward (length)
turtle.right (angle - 360 / count)
turtle.hideturtle ()
turtle.done ()

main (100, 7, 160)
>>
https://en.wikibooks.org/wiki/Haskell/Lists_and_tuples

I'm going through the exercises and I don't understand how they want me to do number 3.

The only way that I can think of since you can only add on the left side is to create a while loop that inverts but they haven't covered loops.
>>
>>54546850
I should specify "
Adapt the above function in a way that 8 is at the end of the list. (Hint: recall the concatenation operator ++ from the previous chapter.)"
>>
Question for you-

Do you think it's better to go through a programming book with pen and paper and take notes with along with it, or to just follow along with a preferred editor?

Both?
>>
>>54546874
Second.
>>
>>54546870
>>54546850
Nevermind I found the solutions page.
>>
>>54546180
>He doesn't know that all programs he compile with Botnet Studio insert a telemetry in the program that make it another botnet.
>>
>>54546874
I always keep notes on paper. It's just nice to have a physical copy.
>>
>>54545296
why does jumping always add a force in the positive X direction, shouldn't that factor in the faced direction/what key is being pressed (move left/right)

Same goes for the wall jump shit

if it has anything to do with the fact that you scale him negatively w.r.t. the x axis, you need to kill this fucking spaghetti now before it gets out of hand.
>>
File: 671.gif (505 KB, 400x406) Image search: [Google]
671.gif
505 KB, 400x406
>>54545296
>WhatIsGround
If you don't know what ground is you need to stop programming
>>
I'm doing intro to algorithms. Not having too much trouble with the procedures themselves but I'm having a hard time grasping the concept of a loop invariant. Any help? Why do I even need this shit it feels like intellectual babble
>>
>>54546180
>not jetbrains
kys
>>
Evening, /g/entlemen.

I'm doing a group project in Qt. Basically, the issue I'm coming to you guys for is not about programming but more about design.

We have to make a game, and like a lot of games it's got a sort of resource system.
We made a dialog window that lets the player pick which resources he wants to trade in blahblah.

So far, we've done everything via a controller to go along with model/view thinking, but now we're disagreeing. Basically, my partner thinks the data side should use signals and slots to indicate when it wants a widget to be called, when I'm more in favor of determining at some point in the controller that the widget has to be called and then passing info on to the relevant class. I hope I explained that clearly enough.

Which approach do you guys think we should pick?
>>
>>54547337
Both sound overengineered.
>>
>>54547361
What do you suggest, then? We've been told not sticking to the model/view thing will get us a zero.
>>
>>54547337
>my partner thinks the data side should use signals and slots to indicate when it wants a widget to be called
Not sure what you mean here. Not that familiar with QT.

How would you describe MVC? It seems to have varying definitions, so I'm curious what interpretation you class is working off.
>>
>>54547377
I suppose if the window isn't modal then you want it to be updated in real-time. Signals/slots sounds like the way to go for this, though. Like >>54547413 said I don't know Qt.
>>
>>54547413
>>54547444

Signals and slots work by connecting a signal to a slot. For instance, if I've got a class for a button, then if it's clicked it emits the "clicked" signal. I can connect that to a slot in the button class itself or in the class that contains the button class.
When it is clicked, the function you put as a slot immediately executes and works like an ordinary function otherwise.

>How would you describe MVC?
Hmm. I'd say it's a way of programming that guarantees the separation between the data and the representation of that data. The main benefit is that the model doesn't need to know anything about how it gets certain information, which allows you to in theory make it work regardless of the UI you decide to use.
The controller class is the class that bridges the gap between UI and data.
>>
>>54547563
What exactly do you need the window to do?
>>
>>54546933
>>54546241
MSVC produces much smaller binaries than any other compiler targetting Windows, and has much smarter optimizations than gcc and similar freetard garbage.
>>
>>54547586
To let the player pick out a bunch of resources. On clicking a button the window would close and another class would be passed the list of resources the player picked.
>>
>>54547654
So is it modal?
>>
>>54547666
Yes.
>>
>>54547654
So >>54547361 was right.
>>
>>54547680
Then I don't see why you need either.
>The most common way to display a modal dialog is to call its exec() function. When the user closes the dialog, exec() will provide a useful return value.
http://doc.qt.io/qt-4.8/qdialog.html#modal-dialogs
>>
>>54547563
Right. So you have a model, which will presumably be a class that contains all the state that the View needs to know about to render the UI.
You have the View, which listens to changes in the model and ensured it is always displaying the data currently in the model accurately.
Then you have the Controller, which is a class that hooks into the View and listens for user input, and updates the Model appropriately. Which should in turn update the View.

It's really weird to try and make a game with QT and MVC. Games generally have much more complicated information about what needs to be rendered than a normal UI application such that MVC shouldn't really suit the problem most of the time. Though if the game is simple it could work.

>should use signals and slots to indicate when it wants a widget to be called
What do you mean my calling a widget here?

>I'm more in favor of determining at some point in the controller that the widget has to be called
Not sure what you mean here. The controller is meant to only listen to the View for input, not directly update things. Though it totally depends on how you interpret MVC. It sounds like you want the Model and View separated though. Having the controller directly update the UI sort of defeats the point of having the Model. Maybe I'm not understanding something though.
>>
>>54547729
Yeah, you don't understand MVC
>>
>>54545097
>mangaka
dropped.
>>
>>54547768
I do though. MVC means different things in different frameworks. Explain what I have wrong.
>>
File: ebin.jpg (163 KB, 1242x820) Image search: [Google]
ebin.jpg
163 KB, 1242x820
I'm editing my DSDT
>>
File: hs-2016-01-p-full_jpg.jpg (3 MB, 1280x1280) Image search: [Google]
hs-2016-01-p-full_jpg.jpg
3 MB, 1280x1280
Tfw NASA has a gallery filled with unlimited, free, HD sky boxes.
>>
>>54547778

The controller doesn't listen for events on the view, the view sends input to the controller.
>>
>>54547680
>>54547712
Forgive me, I assumed by "useful return value" that Qt was being sensible and meant it could be contents of something you set in the dialog, not just whether the OK or Cancel button was pressed.
Still, both MVC and signals/slots seem overengineered, unless you can hook sending the resources to trade along with the "OK" signal.
>>
>>54547812
Splitting hairs.
>>
>>54547812
OSGTP-san!!!

How is the F# going? Thought about trying out any other functional languages?
>>
>>54547812
Does it really make much difference? The input if being forwarded from the View to the Controller. Whether you decide to "push" it or "pull" it is pretty irrelevant to the pattern.
>>
>>54547778
>Explain what I have wrong.
Alright, I'll try and clarify what MVC is in a generalized context.

- MVC doesn't make the implication that a controller shouldn't directly update the view. There are many implementations of things like frameworks where the purpose is to do exactly this. At the same time, there won't always be a need to update a model, and a change in the model does not correlate to your desired change in the view

- Due to this, it's not impractical to make a game based on MVC. There are many JS games, for example, that play out exactly like this

- A widget is usually a small piece of contained software that performs individual things. It can be plugged into many things easily, rather than being tied to any part of the current MVC

- He's more in favour of dependency injection over a listener pattern
>>
Learning a bit of Haskell
Then I should get started on that VM I said I'd start yesterday
>>
>>54547836

The two things are fundamentally different, my guy. MVP is a design where the presenter is completely passive, usually exposing its underlying events for the controller to hook into.
>>
>>54547712
The question isn't how to see that the window's been closed, but more like how to decide when it should be opened.

>>54547729
>It's really weird to try and make a game with QT and MVC.
That's what we were told to do and so because I want to get graded it's what I'm doing.

>What do you mean my calling a widget here?
With this, the class for a card decides it needs to consume resources. It sends out a signal, which is passed along to the controller, and then the controller reacts to that signal and sends back which resources were used.

>Not sure what you mean here.
Well, I'm not directly updating the View via the controller, I'm calling mView->update().

Actually, a different question which I think would pretty much resolve the question for me: should a controller contain logic? If not, then the controller can only work via signals and slots, not the way I'm proposing.
>>
>>54547855
>Does it really make much difference?

Technically. I don't really use either of them and I think architectural patterns are for fags, but everybody and their mommy uses some form of MVC/MVP or whatever.
>>
>>54547870
>writing a VM in a managed language
>>
>>54547851
>How is the F# going?

It's too late, anon-kun. I'm /RacketRocket/ now.
>>
>>54547896
I wasn't going to do it in Haskell, most likely C
>>
File: js.png (24 KB, 500x500) Image search: [Google]
js.png
24 KB, 500x500
Asynchronous JS, Node.js

I have 3 functions f1, f2, f3.

f1(userData) take user data parsed from POST request as paramater.

f1 calls f2, and f2 calls f3.

Function f3 return data that I want to send back to the user with nodejs server response.

What is the proper way to pass it? It takes some time for f3 to finish task before it return value.

Is something similar to this possible?

function onRequest(req, res){

var body = ' ';
requsest.on('data', function(data){
body += data;
}

request.on('end', function(){
var dat = JSON.parse(body);

function result(dat){
//Now I would like to add f3 result as response.write();
f3(dat);
response.writeHead(200, {"Content-Type":"text/plain"});
response.write(How to pass f3 return here);
response.end();
}


}

>>
>>54547900
What is Racket and why is it good?
>>
>>54547922

It's like Scheme, except good. It's good because it's good.
>>
>>54547928
desu Guile > Racket
>>
>>54547922
It's pretty much Python but with Lisp syntax.
>>
>>54547919
In whatever way Node requires, you put response.write in the continuation of f3's asynchronous result.
>>
>>54547919
a callback that's executed after a task finishes like the way gulp works?

sorry my dude, I don't know much node
>>
Am I retarded for not understanding what's being asked here?

Exercise 2-6. Write a function setbits(x,p,n,y)
that returns x with the n
bits that begin at position p set to the rightmost n bits of y, leaving the other
bits unchanged
>>
>>54547946
>Scheme is Python
nice meme, almost as great as the legendary
>JavaScript is Scheme
>>
>>54547919
it should be
function result(dat){
f1(dat);
response.writeHead(200, {"Content-Type":"text/plain"});
response.write(How to pass f3 return here);
response.end();
}

>>
>>54547946
That sounds shit.
>>
>>54547966
I said Racket is Python, not Scheme.
>>
>>54547965
I believe it's saying
ex:
x = 10110010
p = 3
n = 4
y = 5


10110010 - x
1100 - n (4) bits starting at position p (3)
0010 - n (4) bits starting at position y (5)
0010 - 4 bits at p set to 4 bits at y
10001010 - final result
>>
>>54547863
>MVC doesn't make the implication that a controller shouldn't directly update the view.
My understanding is that this was originally the case when the pattern was first devised.

>there won't always be a need to update a model, and a change in the model does not correlate to your desired change in the view
As a matter of practicality sure, but to get the benefit of the pattern you should have all information the view is trying to represent in the model. Unless the framework/language make this too hard to be worth while.

Otherwise the pattern is kinda dumb. The whole point is to keep parts of your logic cleanly isolated. If Controller can update the View directly the the state of the View is dependant on both Controller and Model. Also Controller and View are circularly dependent as Controller depends on View for data and View depends on Controller for data.

Maybe that's what the pattern generally means these days, but it seems better to at least encourage the View to depend on the model only for UI state.

>There are many JS games
That's my point. Simple smalls games can do this. Not so much Quake 2.

>A widget is usually a small piece of contained software that performs individual things
I presumed it has a specific meaning in QT. You just described a module/library/class/function/plug-in
>>
File: tegaki.png (6 KB, 400x400) Image search: [Google]
tegaki.png
6 KB, 400x400
>>54547965
For p = 1 (assuming position goes from right to left) and n = 2
>>
what is the upper most usa company for embedded system programming ?
>>
>>54547965¨
x = 10010010
p = 2
n = 3
y = 11011011


1001 0010
^
p

// so we should set 3 bits where p is pointing at
// using the 3 right most bits in y: 11011[011]

// so x should be:

old: 100[100]10
new: 100[011]10
>>
>>54547990

Finkle is Einhorn?
>>
>>54548078
You should use a useful language like Java or C#.
>>
>>54547887
>I'm calling mView->update().
Is that all you're calling from the controller?

>should a controller contain logic?
of course. it should handle the user input and decide how the UI should update in response, if at all. Potentially all your logic could be contained here.
>>
>>54548054
>My understanding is that this was originally the case when the pattern was first devised.
Not at all.

>The whole point is to keep parts of your logic cleanly isolated.
Under your description, none of the parts are cleanly isolated. The controller talks to the model. The model updates the view. The view may make changes to how the controller works. In this regard, having the controller talk to the view is no different.

>Not so much Quake 2.
I don't think the class project is to make something of the level of Quake 2

>I presumed it has a specific meaning in QT.
No, it has the general meaning when it comes to patterns like MVC
>>
So here in Arduino I'm trying to create an array of objects.

I have a Timer class that contains the minutes, seconds and the name. It has a constructor to give it those values. Now I'm trying to create an empty array of Timer that is 5 slots big. And whenever a new timer starts, it has to initiate a new Timer object in an open slot.

I have absolutely no idea how to figure this out in this language. Should I just do it the simple way and create 5 full sets of global variables? In Java it would take me 5 minutes to do this sheit.
>>
>>54548014
>>54548055
>>54548069
Okay, after re-reading it and looking at your explanations I get it now. Thanks.
>>
>>54548054
Also, a model isn't going to dictate all the information you want in a view. You mentioned how games are complex because there are other factors around them. Same with MVC.

I think you'll find very few MVC implementations where it takes on this imposed restriction. The alternative is to bloat your models in order for your view to know everything only from the model
>>
>>54547919
This advice may be shit because I only taught myself node, but it looks like you can just pass response through the call chain as an argument.

In your declarations of f1, f2, and f3, it would take this form:
function f1(data, res){
// do stuff with data
var newData = data + 1;
f2(newData, res)
}
function f2(data, res){
// do stuff with data
var newData = data + 1;
f3(newData, res)
}
function f3(data, res){
// do stuff with data
var newData = data + 1;
res.writeHead(200, {"Content-Type":"text/plain"});
res.write(newData);
res.end();
}
>>
>>54548115
>Not at all.
I read it was like this with SmallTalk. But maybe I'm wrong.

>Under your description, none of the parts are cleanly isolated.
i don't mean completely isolated. But as isolated as possible while still solving the problem elegantly. You try to avoid the project being a huge blob of code where everything depends on data from everything. You try to enforce limitations and what does what and what has responsibility for what. Not everything should have responsibility of updating the view for example. You try to limit shared state as much as possible and encapsulate it as much as possible.

>I don't think the class project is to make something of the level of Quake 2
Me neither.
>>
>>54548165
>a model isn't going to dictate all the information you want in a view.
it certainly can.

>The alternative is to bloat your models in order for your view to know everything only from the model
This is what MVVM is. It's pretty popular and for good reason.
>>
>>54548191
>But maybe I'm wrong.
You probably just picked up this narrow view of MVC from a popular source

>i don't mean completely isolated. But as isolated as possible while still solving the problem elegantly.
The components ARE isolated under normal MVC structure and your imposed restriction. I'm not saying to mix the V with the C, I'm saying that the C can talk to the V the way other connections between components are made

>me neither
Bit weird of you to mention then

>>54548222
>it certainly can
Sure it can, but it'd be detrimental. Not everything in a view is directly related to a model. Sometimes it's related more to state

>It's pretty popular and for good reason
Agreed
>>
>>54548180
Oh, and if you don't want f3 to directly send the response, you can pass a callback function instead of res in the same manner.
>>
>>54548242
>You probably just picked up this narrow view of MVC from a popular source
I've read that this was the original definition and it's changed since then and the interpretation varies a lot with different frameworks. I never claimed this is what MVC means today and only this.

>I'm saying that the C can talk to the V the way other connections between components are made
yes. This makes them interdependent. Like you say, it's too impractical to have all updates go through the model is most frameworks. I'm just saying it generally good to try to isolate logic in the way I described when you can without too much cost.

>Sure it can, but it'd be detrimental.
But MVVM does this and you think it's good? What's detrimental about it?
>>
>>54548291
>I never claimed this is what MVC means today and only this.
I know. I'm saying you probably picked it up from a popular source. Turns out you picked it up from an old source

>yes. This makes them interdependent.
The logic can be isolated in the same way you can isolate logic between already existing components. If your model has an address, and you change the way that address is retrieved, the view doesn't need to change. If your view decides to perform differently when a signal is heard, the controller doesn't need to change. If the controller needs to change the conditions upon when a signal is fired, the view doesn't need to change

>But MVVM does this
Not sure if you've used MVVM before, but there are things in views that are not related to the model at all. Representing an entire view based on the definition of a model/models is an unnecessary restriction
>>
>>54548112
>Is that all you're calling from the controller?
Not really, no. It also asks for input with pop-up boxes, asking if the player wants to do X or not.
That's all done via that same View class, though. Any interaction with the GUI goes through that class, which is what I think you mean.

>of course
What I mean is game logic. Let me give an example of code in the controller.

    int peopleNumber = mView->pickPeopleNumber();
int placeID = mView->lastClicked();
if(!mGame->setPeopleOn(placeID,peopleNumber))
mView->message("Error!");
else
mView->message("Success!");
if(mGame->isSetPeoplePhaseComplete())
mView->message("Next phase");


Is this okay? I could do it with signals instead, but that would require a lot of extra bullshit.
>>
>>54547928
Racket is scheme you niggerlover.

>>54547946
>its python with lisp syntax
I feel like python is more lisp with C syntax.
>>
>being assigned to make a game in a system that takes control over the message loop away from you AND isn't designed for games in the first place
I pity you.
>>
>>54548291
fyi a pattern does not dictate the sole way of seeing a view

much like pure OO can be restrictive when you want to pass functionality around through functions, MVVM is typically a part of an entire view, the part that lets you talk and interact with the models in a clean way
>>
>>54548358
>Turns out you picked it up from an old source
?? The article wasn't old. All i said is that this was the original definition. As far as I know, I'm correct on that.

>Not sure if you've used MVVM before
I use it all the time. Have done for years.

>but there are things in views that are not related to the model at all.
and?
My point is the "Model" is completely isolated from the View. They only communicate via the View Model.
>>
>>54545017

> people will write a container for the color picker that comes with JavaFX, put their name on it and then post it on shithub
>>
>>54548534
>the View
The part of the view which the MVVM is contained in*
>>
>>54548564
... What? By what logic is "the MVVM" inside the "view" in this case? MVVM is the same of the entire pattern. The "View" is a part of it.
>>
File: dat boi.png (13 KB, 518x329) Image search: [Google]
dat boi.png
13 KB, 518x329
>>54545091
it's hilarious and the hottest meme right now
>>
>>54548587
The View in MVVM relates to the View that the Model and ViewModel talk to, but is only part of the entire page/form's View

Maybe an example will help you understand
I have a view which has an MVVM pattern that lets you change a client's details
In that same view is a file uploader that lets you change the style of the form

This file uploader has nothing to do with the MVVM part of your view
>>
>>54546037
piece a bunch of triangles together

of if it's a line drawing figure out the angles
>>
>>54548624
The Model in MVVM doesn't talk to the View. That's the entire point of the pattern. Many frameworks will let you bypass with View Model, but you are encouraged not to. And some require that you don't.

>In that same view is a file uploader
something that uploads a file would be in the Model part of a MVVM application. The UI for interfacing with the file uploader would be in the VIew.
>>
>>54548668
>The Model in MVVM doesn't talk to the View.
replace talk in my context with 'is referring to in the context of MVVM'

>something that uploads a file would be in the Model part of a MVVM application.
And what model does it refer to? Definitely not the person model
And why does it need to be linked to a model?
>>
Who here is watching eurovision?
>>
>>54548728
What's the point? Emperor Merkel has already decided the winner.
>>
>>54548744
>merkel
>having any power over eurovision

that's not how you spell israel + sweden
>>
>>54548715
>Definitely not the person model
The fuck??

The "Model" in MVVM (also called the "Code behind") is just where all the logic is that doesn't relate to the details of how the UI is rendered. All it does is make sure the View Model contains what should be currently presented to the user via a UI of some kind, and it listens for input from the user from the View Model. It has no idea how the View Model is rendered, or if it is rendered anywhere at all. Maybe it's a desktop QT UI, or maybe it's an iOS UI, or GTK. The model doesn't know and doesn't need to know. That's what the View does in MVVM.
>>
>>54548470
>Racket is scheme you niggerlover.

No, it's not.
>>
>>54548804
Israel was really fucking gay this year.
>>
I have literally zero C++ knowledge, but I want to slightly alter a program written in it: ncmpcpp. Could a C++ wizard help me out?

My goal is to change the tag by which songs are added to the playlist. Right now it adds them based on the currently selected tag.

https://github.com/arybczak/ncmpcpp/blob/master/src/media_library.cpp#L612
    Mpd.AddSearch(Config.media_lib_primary_tag, Tags.current()->value().tag());


I want it to use the "date" tag instead of the currently displayed tag. I assume the "Tags.current()->value().tag()" has something to do with this. Am I crazy for even attempting this without any knowledge or is it indeed kind of easy to solve?
>>
>>54548107
>telling GTP to use C#
how fucking new are you lol
>>54548470
it's not, it's based on Scheme but it doesn't follow most of the recent standards and has a lot of different features: http://stackoverflow.com/questions/3345397/how-is-racket-different-from-scheme. that's why it was renamed from PLT scheme
>>54548844
which is different from any other year how?
>>
File: mvvm.png (9 KB, 531x329) Image search: [Google]
mvvm.png
9 KB, 531x329
>>54548824
>The "Model" in MVVM (also called the "Code behind") is just where all the logic is that doesn't relate to the details of how the UI is rendered.
You're referring to a 'context'. A model is completely different, and a model is plugged into the general view's context

I drew a picture because you seem to be having trouble
>>
>trying out Haskell
>starting to like it
Help, I'm falling for the FP meme
>>
>>54548838
Just because they market it that was doesn't mean Racket isn't Scheme.

I use Racket documentation when scheming. Tell me: what are the differences? They're most likely subtle.
>>
>>54548863
>mild distinction between pairs and mutable pairs
>case sensitivity
>letrec is different
>[] = ()
>more libraries
That's fucking nothing. There's more differences between versions of C.
>>
>>54548870
>You're referring to a 'context'
I'm telling you exactly what MVVM means. Look it up. Model means different things in different patterns.

you would not have a "PersonModel" in MVVM unless it happened to exactly match the data that the Person view needed. "PersonViewModel" would make more sense as it's clear you're describing data that a View UI control might need.

In general you'll have a ViewModel for the entire window.
>>
>>54548954
no, Scheme has a rigid standard. any language that doesn't comply to it is not a Scheme but a Scheme-derivative. different C compilers only act differently on behavior that's left undefined by the standard or by their own extensions. a superset of C is still C, and the same goes for Scheme, but Racket is strictly NOT a superset of Scheme.
>>
How do i make my Qt Widgets Application look good?
>>
>>54548959
>Look it up.
I don't have to, but I can already tell through quick research that I'm right. I'm using it at work for my latest project. Specifically, we're using knockout, which is an MVVM framework, it provides 2-way data binding between a model and the view it relates to through the view-model. However, whole pages and forms are filled with content that don't relate to any model

>you would not have a "PersonModel" in MVVM
Considering a form in a view where a person fills in our details (and this is abundant in our projects), we use this MVVM framework for those parts, and it talks to the Person model. A 'general model' for a specific view makes no sense, is bloated and is too specific

>In general you'll have a ViewModel for the entire window.
I don't know what kind of amateur programs you're working on when all you're manipulating in a window is based on a framework
>>
>>54549005
Then there's never been an implementation of Scheme. Congratulations, the word Scheme is now useless because you think one macro being different and there being immutable pairs is a legitimate distinction.
>>
>>54549052
>Scheme is now useless

:^)
>>
File: index.jpg (3 KB, 165x90) Image search: [Google]
index.jpg
3 KB, 165x90
I'm sorry if this is dumb. Please no bully.

Suppose I am importing three libraries into my Python project (ie. import _____ ):
- One library is MIT licensed
- One library is Apache 2.0 licensed
- One library is GPL licensed

What am I supposed to do in my code so that I can abide by all of these licenses? Tldrlegal explains what I can and cannot do clearly, but their "must" section confuses me. For example, under the Apache 2.0 license:
>Include Copyright
>Include License
How do I include the Copyright and License of the library I am importing into my project? The library has that stuff by default.
>State Changes
If I'm not modifying the library, I don't need to state changes, right?
>Include Notice
The library has this already. I'm not including their entire source code in my software. So all that anyone needs to do is download the library and they'd be able to run it.

It really doesn't feel like I'm redistributing their software. All I'm doing is calling the functions that they defined. Is that considered software redistribution? I always thought that redistributing software involved taking ALL of their code used to make the library and zipping it up and then sharing it. So if I were to download their code, and include it like that into my software, then yes, I would be redistributing their code. But I'm not. Sure, I had to download it to my computer in order to use it. But when I zip up my project, I'm not zipping up that library's source code. I'm just zipping up an import statement to access that library.

Thank you in advance.
>>
>>54549236
>How do I include the Copyright and License of the library I am importing into my project?
Inject it into all your project files
>>
>>54549236
If you're shipping the libraries with your software you'll have to be able to provide the source of those libraries. Otherwise you're fine, as long as your software isn't modifying or overwriting the libraries.
>>
>>54549236
Oh one more thing, this probably doesn't apply to you since you're not tivo, but if the GLP license is version 3, you cannot add DRM to restrict modification of the GPL bits.
>>
>>54545340
This was mainly to improve upon a C library I have to use for one of my classes. It's shit, memory leaks out the ass and it crashes occasionally from conditions it should never encounter (probably because of an ungodly amount of reliance upon undefined behavior). So I'm trying to fix it so the prof doesn't have to give out shitty code to next year's students. Among other things I'm doing besides going through the megadump provided by valgrind is replacing the calls to memcpy and strncpy (which are used throughout) with the safer memmove and strncat. Hopefully that will reveal an error or fix it.

I'm going to make a header that redefines the function calls. That seems to be the easiest way.
https://stackoverflow.com/questions/617554/override-a-function-call-in-c
>>
>>54549236
desu dont do anything unless people specifically ask you. a ton of my code uses libraries by other people that is under different licenses without me even mentioning that any of the code is licensed differently, and i've had some of the maintainers for those other libraries star the projects that use it. 90% of people won't give a shit but if they do i they're gonna inform you on how to fix it rather than suing you
>>
>>54548728
good goy

eh i'll tune in for the heck of it
>>
>>54548804
>+ sweden
do the swedish hosts get this much air time in all countries? like the abba stuff and this thing right now
>>
>>54549911
oh it's in stockholm anyway, then it makes sense
>>
What are the best online or otherwise free sources of information that are best for a beginner learning c++?
>>
>>54550033
cppreference.com
>>
Pls /g/, someone who can into C#, explain to me this I'm very very new, need to add Map interface to windows form, I found this:

http://www.codeproject.com/Articles/32643/GMap-NET-Great-Maps-for-Windows-Forms-and-Presenta

Supposed to be super good and easy but apparently I'm retarded.

I download http://greatmaps.codeplex.com/releases/view/20235, windows form version.

It comes with .exe and 2 .dll files.

I tried copying the code from the codeproject, referenced the .dlls, and created manually MapControl, and now it just won't show and I have no idea how to look up which code .exe that obviously works is running.

Anyone used this, or knows an easy map interface method for windows forms? I've been working on this shitty project for 10+ hours today, this is the last piece
>>
why most open source projects are badly document? sometimes i'd like to help a contribute but it's impossible to study code that doesnt have a single line of code, especially if it's a big project.
How do you guys do it? it seems like only the people that catched the project when it started are the people that continue to contribute.
>>
Anyone have experience parsing JSON?
>>
>>54550033
http://www.cplusplus.com/
>>
>>54550378
>>54550378
https://github.com/stedolan/jq
this is a dream
>>
>>54550311
because it's not fun to write documentation. when im doing an open source project i'm more interested in getting the features down or fixing bugs, since im going to be using it for one of my own projects anyways. in comparison, good documentation requires me to step away from the mindset of the creator of the library and think how to describe everything well. it's a context switch away from programming into teaching and it's not something that most programmers want to waste their free time doing (as opposed to solving problems with code)
>>54550378
yeah, what you wanna know?
>>
>>54550311
The people who write the code aren't disciplined because "comments are boring." One of the advantages code written by corporations has is that discipline is enforced and required.

I feel your pain though. I wanted to inspect Chicken's source code to maybe see how hard it would be to modify the GC to add multithreading, but fuck man the only comments were of the form
;XXX dubious

and whatnot.
>>
File: collapse.jpg (83 KB, 624x658) Image search: [Google]
collapse.jpg
83 KB, 624x658
http://hastebin.com/iteduqocak.cpp

The joke is that it's just a C header file.
>>
>>54550409
thats not an excuse, just a simple explanation about what a method does or what is being done in the next 5 lines is something that doesn't take time and helps people helping you. The same goes for people that want to take your code and make it their own, its impossible for them to do it because it's takes so much time to understand what is being done and what needs to be changed.
Its frustrating

>>54550430
i feel you
>>
>>54550409
Parsing JSON arrays in Java. I only want strings that begin with a certain name, ex. "SortAs".

Do you use org.simple.Json API?

{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}
>>
File: kaneki.jpg (65 KB, 463x470) Image search: [Google]
kaneki.jpg
65 KB, 463x470
>>54545716
Dear friend, have you heard of our lord and savior musl?

http://www.musl-libc.org/
>>
>>54550505
it does take a lot of time. if my code is 10,000 lines split into 100 functions i have to go to write 500 lines of text describing each function just to get those 5 lines.
>>54550520
>Do you use org.simple.Json API?
nope, sorry. but im sure there's a method like findField() or getField() that you could use on whatever the parser returns to get the value of "SortAs"
>>
>>54550171
>http://www.codeproject.com/Articles/32643/GMap-NET-Great-Maps-for-Windows-Forms-and-Presenta

in the future just use Nuget

https://www.nuget.org/packages/GMap.NET.Presentation/
>>
>>54550311
they're made by amateurs
>>
>>54550760
Writing documentation is a pain especially if you are not paid to do it. It's not hard to imagine why documentation often sucks...
>>
Could you guys please help me out a bit?

I can run php files in the shell easily enough like you would javascript or python
however this project I downloaded doesn't have a visible start, like it seems more like a library than anything else

It's here: https://github.com/itafroma/zork-php
Seems like it should be a binary according to the documentation. I installed it just fine but it just downloaded the project directly.
Any help would be appreciated
>>
I'm trying to understand this database C program...

size_t i;
if (conn) {
if (conn->db && conn->db->rows) {
for(i = 0; i < conn->db->max_rows; i++) {
Address *cur = conn->db->rows[i];
free(cur->name);
free(cur->email);
free(cur);
}


what's the advantage of using a size_t iterator over an int?
>>
>>54551403
from the README:
>At this stage of development, there is no working binary, but you can run tests using PHPUnit:
>>
>>54551492
>what's the advantage of using a size_t iterator over an int?
size_t is unsigned, int is signed.
But in this instance I would think max_rows is of type size_t, so they use it to match, don't think there are would be any other reason to use it.
>>
Making a vim undo plugin. Can't find information on parsing undotree() or the undofile() or even programatically getting diff information. Any reading or help anyone can give me?
>>
>>54545452
Sockets
>>
So, what are some easy to code shit that people can find usefull so I can code them for android.

Something like a calendar, a clock, some weather information.

What else?
>>
>>54551605
max_rows is actually an int...
I guess that just makes it a minor mistake then
i understand now though thanks
>>
File: Racket.png (7 KB, 88x85) Image search: [Google]
Racket.png
7 KB, 88x85
>>54547900
>>54547928
Yeah dawg!
>>
>>54548875
good goy
>>
>>54551689
Don't waste your time. Everything's been done already.
>>
>>54548470
>I feel like python is more lisp with C syntax.
What does Python's syntax have in common with C other than using = for assignment?

Lisp stole and plagiarized from a lot of other languages.
>>
>>54551689
A meme machine
>>
>>54551872
>le I'm a mediocre faggot who has no creativity
I just checked all android calculators and there's nothing like pic related.

stay mad because you're an uncreative retard.
>>
>>54551892
you're being lazy, if it's "easy to code" it has most likely already been done pretty well

what so unique about the pic, you just want a simple calculator with a hello kitty skin? be mindful about copyright infringement
>>
>>54551923
and trademarks
>>
Hi /g/, sick of my dayjob so im learning java at home.

Can any of you explain to me why my code can correctly find the amount of prime numbers between 1 - 100 but not 1 - 1000?

while(n <= maxNumber){
if(n % 2 == 0 && n != 2){
System.out.println(n + " is even and not a prime number.");
n++;
}
else if(n % 3 == 0 && n != 3){
System.out.println(n + " can be divided by 3 and is not a prime number.");
n++;
}
else if(n % 5 == 0 && n != 5){
System.out.println(n + " can be divided by 5 and is not a prime number.");
n++;
}
else if(n % 7 == 0 && n != 7){
System.out.println(n + " can be divided by 7 and is not a prime number.");
n++;
}
else{
System.out.println(n + " is a prime number!");
primeCount++;
n++;
}
}


Any advice is welcome.
>>
>>54551492
>what's the advantage of using a size_t iterator over an int?
preventing integer overflows. ALWAYS use size_t
>>
File: calculators.png (415 KB, 1440x900) Image search: [Google]
calculators.png
415 KB, 1440x900
>>54551923
>>54551935
I'm not talking about hello kitty specifically fucking retards.

but there's not a single calculator app that allow you to have custom skins.

>I lack creativity
>>
I'm having some trouble deciding between primary data structures in this game I'm working on. I'm representing entities within a 2D space as a quadtree. I can either wrap the quadtree (which contains the player) in a structure with a separate field for the player, or pass around the quadtree alone between my functions which manipulate it.

The former approach means that I can mutate the player's data without having the walk the tree to find the player, and the player's updated information will automatically be reflected in the quadtree (thanks, set!). However, it also means that all of the main data handlers will have to process the structure and toss aside the player field as they update and render entities in the quadtree exclusively. Processing and manipulating the quadtree directly, without a wrapped structure around it, feels a lot cleaner and more direct. However, to update the player this way I have to walk the quadtree to find it, then update it in accordance with keypresses. That means I might have to walk the quadtree multiple times per tick of time (once to update the player, then again to update the rest of the entities).

What approach do you guys prefer?
>>
>>54551492
size_t is more idiomatic as it's a type intended for memory and offsets. You could probably replace it with int in this case and gain an extraordinarily minor speedup.

>>54551873
Its block style, the way functions are defined, loops, etc is very C-like. The loops and shit are pretty C like. Of course C didn't invent that, but the syntax feels more like C than ML or Lisp.

>stole
>plagiarized
Kek. But yeah stealing from other languages is nice. Lexical scope is nice and I'm glad C and Scheme stole that from Algol.
>>
>>54551979
you can't expect the user to be this much of a dork to set up their own skin for a fucking calculator. you should have different presets to choose from like the one anon made for iOS. or go ahead and make your shitty calc then, no one's stopping you for fuck's sake
>>
>>54551992
Oh you're the asteroid game guy. Never asked, why a quadtree? Wouldn't a hashmap be faster and easier? Your code looked like Scheme, so what about using SRFI-69?
>>
>>54552052
>what are winamp skins
>>
>>54552080
who even uses winamp in 2016 A.D.
>>
>>54546014
How do you ever free your *str ?
>>
>>54552099
>ignoring the point I just told you
do you remember how popular was winamp because of weeb skins?
>>
>>54552122
>/g/ is representative of the world
do you have any sales figures or stats to back that up? and why do you think a calculator is equivalent to a music player?
>>
>>54552122
>winamp with weeb skins
>watching anime streams on winamp SHOUTcast
I miss the good old days.
>>
>>54552144
because why not fucker?

do you think a calculator is a project that would take years?

my only concern now is how can I take a png inside a .zip file and load it into my app.

>>54552149
yeah bro.
>>
>>54552173
yeah why not, go ahead and make your weeb skin calculator app if that's why you want to do, what are you even arguing about
>>
>>54551936
for (int i = 1; i <= 100; i++) 
{
boolean prime = true;
for (int j = 2; j < i; j++)
{
if (i % j == 0 && i != 1)
{
prime = false;
}
}
System.out.println(i + ", " + prime);
}


>>54551505
that's not really helping. How would that help me to be able to run tests?
>>
>>54552173
There exists zip and png reading utilities under the bsdcuck license. You don't need to do it yourself to write that hot app.
>>
>>54552185
why do you seem concerned, I just told you I want to implement diferent small and easy projects in android for fun.

I was looking at some calendar for kids in school to remember their daily schedule.
>>
>>54552221
It seems java has some zip reading capabilities built.
>>
>>54552074
Seemed like an easy-to-implement data structure that cut down on the amount of collision detections I'd have to make per tick. I only check for collisions between the contents of each node. It was fun to implement too. The children of each node are represented as vector of length 0 or 4, so the index elements conveniently represent the quadrants (0 being upper left, 1 being upper right, etc.). I didn't consider a hashmap though. I think I'm going to stick with the quadtree for now, although it's presenting its own problems when used with scrolling. How would I go about using what you're talking about?
>>
>>54552226
you're the one acting abrasive, retard
>>54551892
>>54551979
Thread replies: 255
Thread images: 38

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.