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

/dpt/ - Daily Programming Thread

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

Thread replies: 309
Thread images: 24

File: himegoto considered harmful.png (1MB, 1000x1400px) Image search: [Google]
himegoto considered harmful.png
1MB, 1000x1400px
Previous Thread: >>57410200


What are you working on, /g/?
>>
>>57415523
Is this supposed to be a bad thing?
>>
>>57415525
Who is this semen demon?
>>
Objects. I'm working on objects.
>>
>OOP
>>
File: 1471753599107.jpg (933KB, 1920x1080px) Image search: [Google]
1471753599107.jpg
933KB, 1920x1080px
>>57415583
>>
>>57415523
I'm about halfway through LYAH and I think I'm falling for the Haskell meme.
>>
>>57415534
I think it's parody.
>>
>>57415644
post code and i'll microprettify it
>>
>>57415648
I understand that, but it's parody done in such a way as to make the language (or at least its users) look bad.
>>
Even McCarthy hated the terms 'cons', 'car' and 'cdr'; he tried to promote 'first' and 'rest' instead.

Why do you keep using this archaic terminology?
>>
File: Screenshot_2016-11-06_13-40-21.png (2MB, 1919x1079px) Image search: [Google]
Screenshot_2016-11-06_13-40-21.png
2MB, 1919x1079px
>>57415454
Preach it brother
>>
>>57415534
it's sugar
>>
>>57415721
Yeah the latter.
>>
>>57415724
>not "head" and "tail"
>>
>>57415733
I think he was being silly.
>>
>>57415525
can someone choose a haskell anime girl? if not, i will
>>
>>57415747
That's what I use. Note that I didn't advocate 'first' and 'rest', I just criticised 'car', 'cdr' and 'cons'.
>>
File: ProofGeneral-splash.png (65KB, 310x350px) Image search: [Google]
ProofGeneral-splash.png
65KB, 310x350px
>>57415755
Pleb.
>>
>>57415724
Because lists are made from dotted pairs and there is no word in english for first element of a pair and second element. Rest doesn't cut it, because it's always just one (if compound) element.

cons is short for construct, easy to remember, quick to type. You use it a lot so that's why that's important.

so, since we don't have any proper words car and cdr are fine, also their origin is interesting. Another nice property of car and cdr is that they are easily stackable (cadr, cddr, ...) and have same number of characters, so they align well.

Also everybody knows car and cdr, every dialect has them, while some dialects don't have first and rest.
>>
>>57415782
yeah, I know it takes two seconds to define synonims, but thats already too much effort for such a meaningless matter.
>>
>>57415782
>there is no word in english for first element of a pair and second elemen
how about first and second?
>>
>>57415842
first and second makes you expect third and fourth, which is quite fine with lists, but not with pairs. Head and tail is better, but it makes it seem that there is a difference between the elements. car and cdr is quite fine.

also stackability is the main benefit of car and cdr, being able to use (cadar lst) instead of (head (tail (head lst))) helps readability greatly. Negate this point.
>>
>>57415733
>1919x1079

you wut nigger?
>>
>>57415888
you're using a language where everything is fucking lists

of course it doesn't make any sense
>>
>>57415899
in minimal lisp everything is either an atom or a dotted pair. Lists are just a special kind of a dotted pair, in which cdr is a nil (empty list) atom.

in most lisps you also have arrays, hashes, ...
>>
>>57415888
>also stackability is the main benefit of car and cdr, being able to use (cadar lst) instead of (head (tail (head lst))) helps readability greatly. Negate this point.
How about a fucking 'nth' function instead of retarded nesting?
>>
>>57415967

because it wouldn't be the same functionality. and we already have nth in many lisps (for example racket's list-ref). Problem of n-th is that third element of list '(1 2 (3 4)) is '(3 4), while caddr is 3.

stacking cars and cdrs allows you to access any item in the tree, while n-th only lets you browse the main branch.
>>
which scheme has the easiest c interface?
>>
>>57415585

Why does this answer scare the shit out of me?
>>
>>57416047
chicken. easy use of c libraries is it's main selling point and it has both interpreter and fast compiler to c. you can embed c code into it.
>>
>>57415967
TLDR: Lisp lists actually aren't really lists, they are binary trees made from conses. Lists are the special case when repeatedly applying cdr until you get an atom will give you nil (or the empty list in some dialects).

I.e. (a b c d e) is really sugar for (a . (b . (c . (d . (e . nil)))))

But you could also have something like ((a.b) . (c . (d . e))) which is a binary tree, but can not be rewritten in list notation. At best, some dialects might display it as ( (a . b) c d . e).
>>
File: haskell.jpg (95KB, 480x600px) Image search: [Google]
haskell.jpg
95KB, 480x600px
>>57415782
i use cons to refer to constructing a new list from a head and a tail, but i use head and tail to refer to car and cdr
>>
>>57416221
>everything is btrees
d
u
m
b
>>
File: haiyai.png (173KB, 338x338px) Image search: [Google]
haiyai.png
173KB, 338x338px
>>57416244
binary trees*

>50s (auto)
>tfw
>>
>>57416221

This is an argument of semantics.
>>
>>57416273
>antisemanticism
>>>/pol/

binary trees and lists are not remotely similar
>>
>>57416292
Binary trees and lists are homomorphic.
>>
>>57416273
Yeah, because it's the semantics which make nth function unable to access any element of binary tree, while allowing car-cdr stackings to do so.

Also these semantics fuck many beginners in the ass, since they forget to check if arg is proper list or dotted pair.
>>
>>57416307
Lists of As: X = 1 + AX
Binary trees of As: X = 1 + AX2
>>
>>57416332
Because 4chan hates some Unicode:
X = 1 + AX^2
>>
let s = [round(2**x) | x <- [1..], x<= 10]
take 10 s


why does 4chan think my haskell code is spam
>>
>>57416351
You forgot to write "praise hiroyuki"
>>
>>57416273
No, there are many things you can do with cons cells that you cannot do using only lists, if you care about what the computer is actually doing.

cons/car/cdr are more general than just lists. You should think of cons cells as a fundamental building block for data structures much like pointers in C.
>>
What's the difference between a pointer and a reference in sepples?

Or is that like asking what's the difference between a string and a string literal?
>>
>>57416312
>Yeah, because it's the semantics which make nth function unable to access any element of binary tree,
Any tree can be given a sequential numbering so a function nth(tree, x) can always be made to address any node in the tree.
>>
Why don't programmers distinquish Halloween from Christmas?


Because Oct 31 equals Dec 25!

haha, so funny
got it from an autism forum
>>
>>57416446
that joke is so old that i forgot the meaning

oh wait i just remembered
it's not funny
>>
>>57416406
in which case it's easier to know what are you going to get?
(nth 6 '(a . ((b . c) . d))
(cddr '(a . ((b . c) . d))
>>
>>57416405
A pointer is a variable that may contain the address of another variable.

A reference is creating a new name for a variable, and passing the reference around is only passing the name around.

You can reassign a pointer to a different variable, you can't reassign a reference.

>what's the difference between a string and a string literal?
Pretty big difference actually.
>>
>>57416405
A reference is supposed to always refer to a valid object.
>>
>>57416446
XD I will tell this joke to all of my coworkers
>>
>>57416405
>>57416473
Well, value, anyways.
>>
>>57416464
fucked up the parens, add one to each line -.-
>>
>>57416487
Stop lying, NEET.
>>
>>57416446
what's oct mean
>>
>>57416515
octal, you know the base 8
>>
>>57415897
I have a habit of using my mouse to draw out the region I want to screenshot. I think I've only gotten 1920x1080 perfectly once.
>>
>>57416525
oh, funny.i assumed dec meant decrement
>>
>>57415525
Can someone give me good example or some read with good explonation beyond the standard shit about C and C++ pointers and pointers with objects.

How do they work, what to avoid, what is good practice and how / when to use them ?

Ive been writing and learning C++ for 7 months now but besides the general use and small tutorials with pointers I have not used them in anything serious.

And mostly I am doing stuff with OpenCV and CV in general, still no real use for them.

So I wonder, am I doing something wrong ? If I know how to use them, will I spend less time programming, or actually improve the design of my program ? Or even better, optimize it ?
>>
why are there two threads
>>
>>57416660
the other thread is just trap posting
>>
>>57416660
The other was made before the bump limit and never linked as far as I can tell
>>
>>57416691
it linked, fifth post from bottom up approximately
>>
>>57416711
>>57415527 ? that's this thread you doofus
>>
>>57415525
She's cute. What anime?
>>
>>57416918
Himegoto
>>
>>57416525
that's the (shitty) joke
31st october is the same as 25th december because octal 31 is the same as decimal 25
>>
>>57416375

Yes, I realize this, but to say that LISP lists aren't really lists is just masturbation.
>>
What's the best resource for OS development?
>>
>>57417086
lisp lists are lists, but they aren't one of primitives and the primitive from which they are implemented, is a dotted pair --> binary tree.
>>
>>57410474

# Prints out a pyramid to the terminal consisting of upper case letters, where each
# row is a palomino of the adjacent letters in the alphabet centered at the letter
# of the current row relative to the given letter.
import string


def get_pyramid(letter, rows):
alphabet = string.ascii_uppercase
start_ind = alphabet.find(letter)
# To only print out as wide a pyramid as the
# bottom line:
if start_ind + rows > len(alphabet) - 1:
bottom_length = 2 * (len(alphabet) - start_ind) - 1
else:
bottom_length = 2 * rows - 1
pyramid_str = ""
curr_row = 0
# We dont want to go outside of the alphabet,
# we dont want to make more rows than requested:
while curr_row < rows and curr_row + start_ind < len(alphabet):
# Get left half of current row:
half_curr_str = alphabet[start_ind: curr_row + start_ind]
mid_letter = alphabet[start_ind + curr_row]
curr_line = half_curr_str + mid_letter + half_curr_str[::-1]
pyramid_str += "{:^{}}".format(curr_line, bottom_length) + "\n"
curr_row += 1
if curr_row < rows:
print("Too many rows requested. Returning maximum possible"
" pyramid.")
return pyramid_str

if __name__ == "__main__":
start_letter = input("What is the start letter?: ")
pyramid_height = int(input("How many rows do you want to print?: "))
pyramid_str = get_pyramid(start_letter, pyramid_height)
print(pyramid_str)


R8
>>
>>57417094
This wiki is pretty cool:
http://wiki.osdev.org/Main_Page

You have a few different options:
1. use asm only (templeos)
2. use c with some lines of asm to boot everything up (*nix)
3. use some c and then continue with rust (quite some projects)
4. make a minimal forth intepreter in asm or c and write os in it (was very popular in the past and is one of easier approaches).

more resources:
http://os.phil-opp.com/
https://github.com/organix/pijFORTHos

Lot's of people recommend tannenbaum books, but they have some problems.
>>
>>57417146
and the only candidates harder to read than lisps are ... all other languages except haskell, but especially perl.
>>
>>57417194
Any native language can be used for OS development. It's just a special case of embedded development...

Hell, there's even academic managed OSs running on top of virtual machines that were built to run on bare metal.
>>
        for(size_t l = messages.size() - 1 ;l < (messages.size() - 1) - lines;l--)
{
int output_message = func(messages[l]);
if(output_message)
wprintw(vin,string("<" + messages[l].name + ">" + " " + messages[l].message + "\n").c_str());
wrefresh(vin);
}

How did I fuck this up?
>>
>>57417146
Ment palindrome jesus.
>>
>>57417247
yeah, but these are the usual candidates.
problem with most modern languages is that they expect runtime -- garbage collection, standard libs, ... and you simply don't have this, you have to still provide it.

There was also a significiant minority of lisp oses - google lisp machines. You can't do that with most of modern day lisps, due to afforementioned problems. But a small lisp intepreter is trivial to write in c or even asm.
>>
>>57416061
I don't know anon, but I'm not enjoying myself very much.
>>
c++

void passByRef(int *i);

void passByRef2(int &i);


which is correct? i've been taught both but don't understand the difference
>>
>>57417194
Any idea what determines how "portable" an OS would be? Obviously different CPU architectures would require different compiler options and probably some special case code, but beyond that would you need to specifically code support for different motherboards/chipsets/whatever or would the BIOS handle those differences?
>>
>>57417399
http://stackoverflow.com/questions/334856/are-there-benefits-of-passing-by-pointer-over-passing-by-reference-in-c
>>
>>57417399
First one allows you to reassign i inside the function and you can treat i as an optional value by using null as the invalid value.

Otherwise the only difference is syntactical, second one deson't require address-of and dereference operators.

Personally I prefer the pointer version because it makes it more clear you're passing something 'by reference' at the call site:
passByRef(&someObject); // Immediately upon reading this I know a copy isn't made

passByRef2(someObject); // is it copied or a reference? have to look at function signature
[/cpde]
>>
>>57417422
Most of the c code you are going to write will be portable.

These are 2 things that you have to write in assembler:
1. bootloader (or just use grub, lilo, etc.) or
2. some code for configuring grub, any other bootloader

Any code in asm isn't portable. Another problem for portability are drivers.

If your *nix requires drivers for some hw, your os will need them too. if it doesn't, you are probably safe.

Some advice:
- don't focus on portability too much in the beginning, your first os won't be your best os
- use emulators like qemu
- don't write your own bootloader, seriously, it's one of the hardest parts of os
>>
>>57417439
>>57417482
thanks
>>
>>57417525
>don't write your own bootloader, seriously, it's one of the hardest parts of os
Uh, no. It's not even close to one of the hardest things.
A minimal bootloader is just switching to protected mode and loading the kernel code.
>>
File: terrrrrrrrrrrrrrry.png (218KB, 1641x366px) Image search: [Google]
terrrrrrrrrrrrrrry.png
218KB, 1641x366px
>>
>>57414809
hahahhahahhaahahahaa
>>57417216
to be fair
doing string shit in lisp is undesirable
symbols are better
>>
holly fuck, ocaml is unreadable
and they have the Maybe data time, but they're called options?
I bet it doesn't even have classes like haskell does
and no purity too, yuck
>>
>>57417618
the only advantage of ocaml over haskell is speed, and even here haskell is slowly overtaking it.
>>
>>57417618
Option doesn't actually bother me desu, it's just that it's a different convention
>>
>>57417525
>- don't write your own bootloader, seriously, it's one of the hardest parts of os
Not really.
You just need to setup your environment (descriptor tables, paging, protected, long mode, etc) load some bytes from disk. Doesn't require much code at all. I would say getting multitasking up and running is much more challenging.
Especially easy if you want to use UEFI (don't even need any assembler, UEFI can even take care of putting you in long mode with 1:1 paging).
(Of course it can be a complete distraction since it doesn't really have anything to do with the rest of your OS development.)
>>
I'm kinda new to programming and I'm absolutely stumped on a solution. I'm trying to check for duplicates of something in a list to determine uniqueness.

How could I do this?
>>
File: Problem2.png (21KB, 444x684px) Image search: [Google]
Problem2.png
21KB, 444x684px
Hi, could anyone help me understand why I keep receiving this error & a solution to fix it?

Thanks
>>
>>57417745
The naive way is to sort the list and check if two adjacent items are the same.

The O(n) space way is to go through the list and put evrything into a hash table, if you get a collision that's a dup.
>>
>>57417745
naive and slow solution:
for every element in list
remove that element from list
check if element is still member of list

or just sort the list and check adjacents
>>
File: yotsubaSureHopes.jpg (55KB, 263x237px) Image search: [Google]
yotsubaSureHopes.jpg
55KB, 263x237px
>>57417803
>for every element in list
>remove that element from list
>check if element is still member of list
>>
>>57417745
foldr foo []
where foo x xs | elem x xs = xs
| otherwise = x:xs
>>
Can someone suggest a way to open a website from C using a variable in the URL?
Like if I want to open
http://www.test.com/ID
where "ID" is an int variable.
>>
>>57417868
yes
>>
>>57417868
I can
>>
>>57417814
; return true if any element occurs more than once in lst
(define (duplicates? lst)
(cond ((null? lst) #f)
((member (car lst) (cdr lst)) #t)
(#t (duplicates? (cdr lst)))))
>>
>>57417903
This is is slightly less retarded, since you're not removing from the list, but still pretty damn stupid.

Only an academic can write code that bad.
>>
>>57417777
problem of sort is if you have different data types in list, for example numbers, chars, strings, symbols, more lists.
>>
>>57417890
>>57417897
Tell me please?
You can get a cute anime pic as reward.
>>
>>57417932
>You can get a cute anime pic as reward.
If you find me a cute pony, I'll tell you ;^)
>>
>>57417917
oh but I am removing, since i am testing first element against rest of list. And in recursion step I don't pass entire list forward.

But yeah, I admit it's retarded. If I ever needed to do this in real life I would use hash table approach.
>>
Currently working on a basic Calendar CLI application, tying to get practice with classes, and I'm getting a bit of an error.

I define all my "Month" functions in "month.h" and implement them in "month.cpp", yet my IDE complains that I'm re-defining functions.

Specifically, this is my error message:
empty-project\month.cpp:3: error: multiple definition of `Month::Month(std::string, Day, int)'
empty-project\month.cpp:3: first defined here


And here's my code for my Month header and implementation:
/* Header */
#ifndef MONTH_H
#define MONTH_H
struct Day{
int dayNum;
int weekDay; //Sunday = 0, Monday = 1, ... Saturday = 6;
};

#include <vector>

class Month{
public:
Month(string monthName, Day initialDay, int numDays);
void printMonth();
private:
vector<Day> monthVector;
};


/* Implementation, month.cpp */
#include "grid.h"
#include "month.h"


Month::Month(string monthName, Day initialDay, int numDays)
{
int startWeekDay = initialDay.weekDay;
for(int day = 1; day <= numDays; day++)
{
int weekday = (startWeekDay+day)%7;
Day currentDay;
currentDay.dayNum = day;
currentDay.weekDay = weekday;
monthVector.push_back(currentDay);
}
}

void Month::printMonth()
{
for(Day currDay: monthVector)
cout << currDay.weekDay << "\t";
cout << endl;
for(Day currDay: monthVector)
cout << currDay.dayNum << "\t";

}


Any tips?
>>
>>57417903
I dig that racket uses ? instead of P for predicated
>>
>>57417942
Arguingly you're not removing anything, you're just moving through the list and forgetting what was there before, but at the end you still have an intact list.
>>
>>57417775
I think you want to change the
 (new PackOfCrisps(PackOfCrisps));
to
 (new PackOfCrisps(packet)); 


PackOfCrisps is a type name so you can't pass it as a parameter, it isn't an actual object, just a class name. I can barely read that freakin IDE though.
>>
>>57417950
yeah, most schemes and scheme descendants use them.

>>57417956
yes, but alghoritm would be practically same with mutable lists.
>>
>>57417958
rereading that again I actually have no idea what needs to go in the parameters, whatever the constructor of PackOfCrisps accepts, honestly just look there.
>>
>>57417938
Sure
https://is.4chan.org/mlp/1478470726383.png
>>
>>57417958
>>57417980
It is meant to store an object that is already created, but for the life of me will not stop giving me that error.
Also sorry about the IDE.
>>
>>57417775
You're still on this shitty exercise lmao
>>
>>57418021
>Worst pony
Anon, please.

Anyways, just use snprintf and run a web browser:

char cmd[255];
int id = 12345;
snprintf(cmd, sizeof(cmd), "firefox http://www.test.com/%d", id);
system(cmd);
>>
>>57418097
What object though? Where is that object declared and instantiated? And if it's already created, why are you using new?

PackOfCrisps is clearly a type name and not a variable name, as that is the parameter TYPE of void addPack.
>>
>>57417775
java, not even once
>>
>>57417950
also type conversion function naming is fucking sweet:
number->char
string->list
list->string
etc.
>>
>>57418123
Thanks, mate :^)
>>
>>57417775
why did you write this?
note first that "packet" refers to two things here. this.packet (i think; i don't write a lot of java) is your internal list of packets and packet is this new packet
you want to add packet to this.packet. i don't see the need to create a new object -- you already have all the objects you need
>>
>>57417945
>all this PascalCase

Can we please kill this standard? It does NOT help readability.
>>
>>57418169
struct Message {
Message(string ch,string usr,string msg)
{
channel = ch;
name = usr;
message = msg;
}

string channel;
string name;
string message;
};

class ChatLogger {
public:
void addMessage(Message msg)
{
messages.push_back(msg);
}

void writeOutLinesLambda(size_t lines,function<int(Message)> func)
{
if(lines > messages.size())
lines = messages.size();
if(messages.size() == 0)
{
return;
}
size_t l = messages.size() - 1 ;
do{
int output_message = func(messages[l]);
if(output_message)
wprintw(vin,string("<" + messages[l].name + ">" + " " + messages[l].message + "\n").c_str());
wrefresh(vin);
l--;
}while(l > (messages.size() - 1) - lines);

}

void writeOutLines(size_t lines)
{
writeOutLinesLambda(lines,[=](Message msg){ return true; });
}

private:
vector<Message> messages;
};

struct RemoteUser {
RemoteUser(string name_temp,autobahn::wamp_subscription subscription_temp)
{
name = name_temp;
subscription = subscription_temp;

}

string name;
autobahn::wamp_subscription subscription;
};

struct User {
string name = "not_connected";
string channel;
vector<RemoteUser> channelusers;
vector<unsigned char> pubkey;
vector<unsigned char> privkey;
};

:^)
>>
>>57418169
it's even worse, it's pascalCaSe

why don't more folks adapt kebab-case? arguably it's one of the most readable and aesthetical ways.
>>
>>57418203
Why don't people use trap case with a non-breaking space between words?
>>
>>57418214
why aren't variable names just utf8 strings...

Imagine:

"°žšLł˛    @\n\r\b\n" = 23
>>
i wonder if the person who made the online learn you a haskell webpage purposefully made the pages tremendously long so you can't bookmark where you left off when you stop
>>
File: 1356785154050.jpg (96KB, 500x746px) Image search: [Google]
1356785154050.jpg
96KB, 500x746px
How can I see possible unhanded exceptions thrown by a particular block in VS/C#?
Unlike Java/any IDE, it doesn't seem to tell you what might actually be thrown.
>>
Can anyone help explain this sierpinski triangle code? I can't understand the black magic inside the function. Specifically lines 4 and 5.

def sierpinski(n):
d = ["*"]
for i in xrange(n):
sp = " " * (2 ** i)
d = [sp+x+sp for x in d] + [x+" "+x for x in d]
return d

print "\n".join(sierpinski(4))
>>
>>57418358
Draw it out. You can concatenate strings with arithmetic operators in Python.
>>
>>57418358
Line 4 assigns a string to variable sp that consists of power(2, i) spaces.
Line 5 creates two lists, one that consists of the spaces plus * plus spaces again for each element in d then adds another list to that that consists of * plus space plus * for each element in d.
>>
>>57418358

My ruby/python is a little rusty, but let me try:
4. generates 2^i long string of spaces
5. appends together two strings. First string is appended from 4. "*" and 4., second string is appended from "*" " " and "*"
>>
write a program to find all a, b, c, and d where a^3 + b^3 = c^3 + d^3 where all a,b,c,d are a thousand or less

answer = [(x, y, a, b) | x <- [1..1000], y <- [1..1000], a <- [1..1000], b <- [1..1000], (x**3 + y**3) == (a**3 + b**3)]
>>
Does any kind of shader or general math knowledge exist to pull the kind of fractal effects on existing meshes seen at

https://www.youtube.com/watch?v=34-crXXPtko&feature=youtu.be&t=90
?

Obviously a lot of it is non-fractal, but there are some very obviously (to me) fractal effects happening on the window panes. There are better examples in the movie, but I can't find them online since it's just been released.
>>
I have a Java class next semester so I've been playing with Eclipse and Intellij IDEA on Linux to see which I like better.
Right off the bat with Eclipse I notice it wants me to use a fucking installer. It even defaults to installing into my god damn Home folder. Is this piece of shit even worth using on Linux? Clearly this program was made for winbabbies.
Meanwhile had no problems getting Intellij to install(and in the proper folder too), got it up and running and everything works great outside of the disgusting font rendering.

You guys have any opinions on the two?
>>
>>57418422
>>57418393
>>57418427
Cheers guys, but I have no problem reading the code. It's just that I cannot for the life of me get an intuitive understanding of how it generates the Sierpinski triangle.
>>
In assembly, if there is no jump instruction, does the code just continue down the rest of the instructions?
i.e.
If another block jumped to L12

.L12:
movl 8(%ebp), %eax
movl num(,%eax,4), %eax
movl %eax, -24(%ebp)
.L6:
movl -24(%ebp), %eax
addl $28, %esp
popl %ebx
popl %ebp
ret

Then when it reached the end of .L12, it would just start L6?
>>
>>57418458
>winbabbies
Oh god, you're that guy in the class.
>>
>>57418473
Yes.
>>
>>57418464
you've been very unclear on what your understanding of this object is
>>
>>57418464
Well then you infact, can't read it.
>>
>>57418473
Yes.
>>
File: 1472615200243.jpg (311KB, 2094x2095px) Image search: [Google]
1472615200243.jpg
311KB, 2094x2095px
>>57417643
>speed
>slowly overtaking
>>
File: 1461737108240.png (860KB, 841x720px) Image search: [Google]
1461737108240.png
860KB, 841x720px
>>57418482
I don't think you belong here, mate.
>>
>>57418514
okay, lazily overtaking it
>>
>>57418482
Nah, that's how the whole class is. The majority of the core classes are in C with Linux and vim as the standard. Only the gamerfags and poo in loos actually use windows.
>>
>>57418518
I don't think you belong in the daily programming thread if you can't program in Java.
>>
>>57418558
LOL
>>
>>57418455
Could probably be done with displacement mapping, or hell, even simpler, just plane deformations on the texture coordinates.
>>
File: dr. pepper.jpg (58KB, 460x522px) Image search: [Google]
dr. pepper.jpg
58KB, 460x522px
Can you learn to intuitively understand hex like you understand decimal?
>>
>>57418608
Well, yeah. Why not?
>>
>>57418473
> Then when it reached the end of .L12,
That's gibberish. L12 just is a label, it doesn't have an "end".

The CPU executes instructions in sequence unless something causes it to do otherwise (jump, branch, return, direct store to IP, interrupt, etc).
>>
>>57418532
8/10, would chuckle again.
>>
>>57418590
I don't think so. If you look closely, it looks like the geometry is multiplying and folding in upon itself in some mathematical way. I wish I had access to scenes later in the movie, because they show it a lot better.
There's a chance it was done by hand, but I'm willing to bet that they used math trickery.
>>
>>57418649
>L12 just is a label, it doesn't have an "end".
Yes and no. You're right that it's just a label in ASM, but from the PoV of the compiler it's actually the start of a basic block, so it sort of does have a start and an end in exactly the way anon though.
>>
>>57418455
It just looks like they're adding more bars and moving them across, no fractals involved.
>>
>>57418663
It doesn't matter what the compiler thinks. The CPU just sees instructions.
>>
>>57418673
Yeah, I'm just saying it's not a wrong mental model.

[>spoiler]And actually the compiler does care about basic blocks due to branch prediction[/>spoiler]
>>
realized i was using vi not vim
>>
>>57418608
Can I please get the sauce for this finally?
>>
>>57418608
what do you find intuitive about decimal?
>>
File: 1366310271822.png (39KB, 574x226px) Image search: [Google]
1366310271822.png
39KB, 574x226px
>>57418558
I can I just want to know what you guys thought of those two IDE's on Linux.
>>
>>57418686
>>57418673
>>57418649

Yeah I know it's not actually a block per se, I just wanted to make sure. Assembly is fucking weird
>>
>>57418695
When I see a number like 224 I know how much that is, but when I see E0 I have no clue without converting it to decimal first.
>>
>>57418708
>Assembly is fucking weird
x86 assembly is fucking weird. If you've used a nice RISC assembly, it's a lot nicer.
>>
>>57415525
well i coded the logic for the game cows and bulls but needed it to where user input has to be unique digits.

i did this algorithm kek i'm kinda retarded but very NEW to coding. I guess this hack works for telling the user to not have repeating digits in their output.

counter = 0 
x = 3
string = '2888'
newstring = '1883'
l = []
l2 = []

while x >= 0:
for i in range(0, 4):
l.append(string[i])
l2.append(newstring[x])
x -= 1

for i in range(0, 4):
if l[i] == l2[i]:
print(l[i])
>>
>>57418717
That's easy, E0 is almost 100 which is around the number of spaghettis you can fit in both your pockets
>>
>>57418718
Unfortunately the class I'm taking is explicitly in x86
>>
>>57418704
stop being a whiny crossdresser and map up faggot. jesus just fucking use eclipse, you think there's better for fucking java?
>>
>>57418736
yeah, emacs and vim
>>
>>57418704
IDEs are shit. Just use a decent text editor.

>>57418558
How is what I said indicative of my knowledge of pajeetlang?
>>
>>57418717
well you've been force-fed decimal your entire life. of course it's not automatic
it's nice to have a base that matches up with your fingers but i don't see any other great advantage to base 10
other cultures have used different bases. maybe that's why they died
>>
>>57418736
But it runs like shit.
>Can feel delay when typing
>Wants to install itself in the Home folder like it's on windows
>Icon doesn't even open the application

Intellij just werks but the font rendering is god fucking awful compared to when I open the same file in Vim or even Eclipse.
>>
Are the SICP mit 6.001 1986 lectures better than the book? or should I just read the book?
>>
>>57418730
enter a four digit number: 3333
no repeating digits
enter a four digit number: 1223
no repeating digits
enter a four digit number: 1234
0 cows 2 bulls
enter a four digit number:


here it is in action. Now just have to make sure the random number the computer generates doesn't have repeating digits as well.
>>
>>57418812
did you search around? i'm sure people have run into this issue with intellij before
>>
>>57418358
Guys. you should run this but pass it 1000. Looks pretty cool.
>>
>>57418458
Just... use your package manager.

https://packages.debian.org/stretch/eclipse
http://packages.ubuntu.com/yakkety/eclipse
https://apps.fedoraproject.org/packages/eclipse
https://www.archlinux.org/packages/?name=eclipse-java
>>
>>57418812
Try netbeans :^)
>>
>>57418814
Just do both and LARP as if you were a real MIT student in the 80s.
>>
>>57418458
see >>57418850

you also won't be able to remove it with your package manager since you didn't use it to install
>>
>>57418863
but its 2016
>>
>>57418863
So... no computer except once or twice per week in lab in controlled envirovment and doing evertyhing with pencil and notebook? great

But seriously, if this handwriting doesn't make you understand computation nothing will.
>>
>>57418876
no, its two thousand years ago.
>>
>>57418800
>it's nice to have a base that matches up with your fingers but i don't see any other great advantage to base 10
There are a lot of arguments for using base 12 (e.g. lots of factors, so it splits into fractions nicely), but in a world with calculators so easily accessible, those arguments become irrelevant.

>>57418717
If you're just using hexadecimal to represent arbitrary numbers, you're doing it wrong.
Hexadecimal is useful for representing binary strings without it being long as fuck. Each hexadecimal digit is 4 bits, and each pair is a byte. If you actually care about the decimal value, which you probably shouldn't most of the time, just do the conversion.
>>
data work.shitpost;
input shit $ post $;
datalines;
hello 4chan
how goes?
;
run;
>>
>>57418659
Plane deformations is 'math trickery' - it's transforming the uv coordinates so the texture appears to animate.
Looking at it more closely I reckon you can achieve something similar with texture feedback + transforming the uv coordinates.
>>
>>57418458
wait... where would you expect eclipse to install itself if you run it unprivieledged? in /opt? but that's not world-writable...
>>
>>57418857
whtas the problem with beans? newguy here....
>>
>>57418437
How long did it need to compute?
I guess imperative guys are ignoring this for a good reason.

Will post racket naive solution when it finishes computing.
>>
>>57418835
Yes, other people had similar problems but their solutions either did not work for me or I didn't feel like trying because it was too long. I could fix it if I spent the time I'm sure.

>>57418850
>version 3.8
Deprecated. Eclipse is at 4.6

>>57418857
:^)

>>57418915
Running the installer as root lets you install it to opt but after installation it will not run at all. The only way to get it into /opt I've found is to dl the tar and put it there yourself like any normal linux program. Of course, the installer doesn't even fucking work.
>>
if(post.anime?()){
block(post);
System.out.println("Blocked");
}
>>
>>57418814
please respond
>>
>>57418950
i'm not computing that lol. i don't want to break my laptop. it works though
>>
>>57418976
read the book, lectures are a bit slow.
>>
>>57418976
why don't you read the section of the book the lecture is on before and after watching each lecture? that's the best way to learn, especially if you're seriously about learning it
>>
>>57418994
do they cover everything though?

>>57419003
I love learning by lectures, just worried if the lectures are outdated compared the 2nd edition of the book
>>
>>57418989
i guess i will see my solution in the morning :P

do you perchance know how yours is actually computed? how and when are tests applied?
>>
>>57418814
this is a person question, isn't it? i know moocs are all the rage but i prefer books. in this particular case the lectures are so nice that i watched them for fun, but you really do have to figure out what works for you
>>
>>57419018
It's mostly the same. they changed some exercies, but core materials stayed unchanged.
>>
>>57419019
>>57418989
also i am amusing that a != b != c != d
>>
>>57419051
i think you amusement is different from what the book says, it doesn't say that they have to be unique. this is a prob from cracking the coding interview
>>
>4chanX adds a download image button in the update 5 minutes ago
>still no fucking filter md5 button to shift through spam

Just venting, but just incase ccd0 watches these threads, I want him to know this is bullshit.
>>
>>57418133
I phrased that wrong, I meant that the class is already created for PackOfCrisps & that I thought you used new when creating a new arraylist to store the object made from the class.
Or do I have that wrong (probably do)
>>
>>57419019
it brute forces it, no other way
>>57418950
imperative way would just be 4 nested loops, same brute force just not looking as pretty
>>
>>57419051
Out of memory error...

>>57419072
>>57419051
*assuming goddamit
for now it's assumed that they are unique, maybe i will fix it tomorrow.

(define (cube x)
(expt x 3))

(define all-possible
(combinations (range 1 1001) 4))

; takes a list of four elements
; if a^3 + b^3 = c^3 + d^3, where a is car, b is cadr, c is caddr and d is cadddr,
; is true return #t
; else #f
(define (cube-sum-equals? lst)
(let ((a (car lst))
(b (cadr lst))
(c (caddr lst))
(d (cadddr lst)))
(if (= (+ (cube a) (cube b))
(+ (cube c) (cube d)))
#t
#f)))

(filter cube-sum-equals? all-possible)
>>
>>57419113
bretty good, now you have to actually use scheme in any coding interviews you have in the future though
>>
C++ books?
>>
>>57419085
Yeah I know the class is created. If you want to add a new object of type PackOfCrisps, then just type

packet.add(new PackOfCrisps());


The parameter on new PackOfCrisps is what's passed into the constructor of that instantiated object. See up where it says public SnackMachine(), and there's empty parameters? If there was a variable like (int i) in there, you'd pass it in with

 new SnackMachine(2); 


When creating the object.

Also, for what purpose does addPack accept a parameter "packet"? If you're referring to the private packet arraylist in the class, then there's no need for it, if you want to pass it in and use it, rename it or use
 this.packet 
to refer to the classes instance.
>>
>>57419150
A: Belong into trash.
>>
>>57419150
The C Programming Language, second edition (ANSI C) by Brian Kernighan and Dennis Ritchie.
>>
>>57419150
C++ Primer. The C Programming Language by K&R. C is a subset of C++ so it's good to know C.
>>
>>57419145
racket actually, if it was scheme i would have to define at least combinations.
>>
>>57419179
Thanks
>>
>>57417852
nub
>>
>>57417852
why are you getting it from a folder though? why don't you post the code in there
>>
>>57419190
>>57419145

also thanks, i am sure there is some worse fate.
>>
How long does it take to finish a book to you guys?
>>
>>57415525
Guys, I need some help with this javascript thing.
I've a function that creates an html table dynamically. When a cell is clicked, it triggers a function.
How can I make the function to have access to the coordinates on the table of the element that triggered it?
>>
>>57419218
i finished 400page design of unix os in 3-4 days (vacation, had a lot of time), but now i am slowly slouching through 1600page tcp/ip guide for close to 2 weeks.
>>
In Cucumber, how would I make sure than jewgle search returned relevant results?

Do I check to see if the browser title starts with my query?
>>
I don't get it, isn't OOP functional programming just with different ways to call those functions?
whats the problem
>>
>>57419392
oh and it actually requires you to organize everything, which is good
>>
>>57419392
no
>>
>>57419392
define oop
define functional programmign
>>
>>57419392
it's like the matrix, you have to see it for yourself. learn haskell
>>
>>57419392
They're mindsets. OOP is organizing your program as a system of interacting actors. FP is organizing your program as a transformation of state.
>>
>>57419476
oop- extending the language by calling data (organized abstractions)

functional programming-making abstractions part of the language
>>
give me the essential computer science books. not $100 textbooks and not books on specific languages, unless it only uses that language to convey concepts
>>
>>57419593
"How to Google in 3 easy steps" by Whitehead and Russel
>>
>>57419605
doesn't give me any results when i enter it into google
>>
File: carrot.jpg (234KB, 620x929px) Image search: [Google]
carrot.jpg
234KB, 620x929px
>>57419633
Try to bing it
>>
>>57418772
>IDEs are shit. Just use a decent text editor.

Why do people say retarded shit like this?
If you want to work with any modern language, or in any modern company, IDEs are significantly better because they offer you a whole host of tools to make you work faster.
>>
>>57419113
>adr
>addr
>adddr

how deep does the rabbit hole go?
>>
>>57419653
>they offer you a whole host of tools to make you work faster
Like?
Also, are you implying that text editors don't have tool to increase your efficiency?
>>
>>57419677

caddadddaddadadadaaaadddadadddaddddadadr
>>
>>57419698
Like: Package managers, integrated support for tools like Git, automatic multifile editing (I.E. moving files in the hierarchy can change things in your buildfile or whatever else your language uses to compile.deploy), official support from software developers (Android studio integration as an example), etc.
There's just absolutely no reason to use text editors. Sure, IDEs might not offer anything that a text editor wouldn't for programming in C with no dependencies (other than, of course, advanced controllable breakpoints, interactable callstacks, and other debugging features) but even in that instance text editors don't offer anything that IDEs don't other than being slightly more portable.
>>
>>57419653
are we talking about working at a company or personal computing? because if you're at a company, you're going to be using their IDE regardless. that doesn't mean you need to be reliant on an IDE for your own computing and have no idea what to do when you have to do something it doesn't support
>>
>>57419677
you can make a macro which makes a function based on a sequence of a's and d's
>>
>>57419746
>integrated support for tools like Git
you know what else has integrated support for tools like Git? linux. also, you don't actually know how to use Git if you only use it from an IDE. legitimately stopped reading your post there
>>
File: feelsbadman.png (46KB, 1378x793px) Image search: [Google]
feelsbadman.png
46KB, 1378x793px
how can i make it print actual spaces instead of numbers when the message is translated without completely changing the code?
>>
File: feelsbadman2.png (42KB, 1380x781px) Image search: [Google]
feelsbadman2.png
42KB, 1380x781px
>>57419804
removed useless code
>>
>>57419804
i'm sure you can think of a way
>>
>>57419801
Good to know that you stopped reading my post and missed literally everything else that you get from an IDE so you can continue being a retard
also
>Implying I can't use git bash
>Implying that it's a good thing that git bash is unnecessarily convoluted
>Implying that lots of developers don't waste a shitload of time/accidentally delete important shit learning git
If you think that it's good that version control is even remotely difficult to use then you're retarded. Being able to simply have shit right there that doesn't require you to tab out of your dev window is pretty gr8, even if you otherwise do know how to use it.
>>
>>57419840
ye on second thought no one answer, ill keep trying to figure out by myself
>>
I use a text editor over an IDE if only because I can actually have the text editor open on half my screen while the other half has something else (documentation, paper, file browser, terminal, 4chan, etc.). IDEs always take up too much space to do that comfortably.
>>
>>57419843
you value ease of use of flexibility which is fine, but you should keep it to yourself pajeet
>>
>>57419889
Explain to me what text editors can do that an IDE can't.
>>
>>57419900
Explain to me what IDEs do that a text editor can't.
>>
>>57419908
I just did
>>57419746
IDEs massively increase the speed at which you work.
>>
>>57419919
They make certain things easier but they don't make new things possible. And there are trade offs.
>>
>>57419932
I just said a bunch of things that are possible in IDEs that don't exist in text editors
>Detailed/highly customizable breakpoints
>Inspectable callstacks
>Inspectable breapoints
>Package managers
>Official support/integration from large companies
>>
>>57419919
I've never used a text editor that's built into an ide that was as good as sublime's.
>>
>>57419677
Racket has pattern matching/destructuring...
(define/match (cube-sum-equals lst)
[((list a b c d)))
(if ...
)]
[(_) (error "invalid input")])
>>
>>57419932
Also
>Trade offs
There are no trade offs because text editors can do NOTHING that IDEs can't use

>>57419963
http://www.telerik.com/blogs/sublime-studio-replicating-sublime-text-2-features-in-visual-studio
>>
>>57419961
That's because IDEs just integrate tools like debuggers and whatnot instead of having the user do that all separately.

In isolation, I guess an IDE is never going to lose to a text editor because they come with more things.
>>
>>57419982
Emacs is both an IDE and a text editor. Why are you even having this argument?
>>
So ive learned basic c++, now what?
>>
>>57419987
Thank you, this is the point I was trying to make.
I'm /not/ saying that text editors are useless, I'm just saying that they aren't as usful as IDEs and recommending newbies to use them is a terrible idea.
>>
>>57419982
Text editors are more efficient. They are more customizable. They are more portable. They are designed to work with any language, not just a few.
>>
>>57419982
>Visual studio
>Spending two minutes for it to phone home and load up
Kill yourself?
>>
started working through the odin project.
>>
>>57420057
>two minutes
10 seconds.
>kill yourself?
Nah, I'd gladly take the 10 second load in exchange for saving about half an hour every single day on shit it automatically takes care of for me.

>>57420002
>efficient
At what? Getting work done? No, they categorically aren't given all the shit that IDEs offer to speed workflow.
>Customizable
Some text editors may be more customizable than some IDEs but IDEs offer customizing where it matters more, like functionality instead of looks(I.E. package managers). That being said, most IDEs let you edit the look just about however you want.
>Portable
Yeah, but when are you going to need to settle down to some random-ass computer and begin developing? Do you always keep a flash drive on you with your text editor set up as you want it or what?
>They are designed to work with any language
Most IDEs can deal with just about any language you need them to, and have plugins for every/any language.
>>
File: 1444785042218.jpg (31KB, 192x452px) Image search: [Google]
1444785042218.jpg
31KB, 192x452px
>ask about Intellij vs Eclipse
>instead delve into a IDE vs text editor debate
Man, you guys could at least have the decency to autistically argue about what I wanted.
>>
>>57420113
>At what? Getting work done? No, they categorically aren't given all the shit that IDEs offer to speed workflow.
More efficient with your computer's resources. More efficient with screen space. They're more responsive.

>Some text editors may be more customizable than some IDEs but IDEs offer customizing where it matters more, like functionality instead of looks(I.E. package managers). That being said, most IDEs let you edit the look just about however you want.
>Most IDEs can deal with just about any language you need them to, and have plugins for every/any language.
No better than text editors, then.

>Yeah, but when are you going to need to settle down to some random-ass computer and begin developing? Do you always keep a flash drive on you with your text editor set up as you want it or what?
Your personal experience doesn't matter.
>>
>>57419961
>Detailed/highly customizable breakpoints
>Inspectable callstacks
>Inspectable breapoints
I have those in my debugger.
>Package managers
Already part of my OS.
>Official support/integration from large companies
Useless.
>>
>>57419995
Now you learn C++.
>>
>>57419831
holy shit im so fucking stupid, figured it out though
>>
what is a good scheme compiler?
>>
scheme is fun as fuck wtf
>>
>>57420113
everything you do in your IDE, i can do without my fingers leaving the keyboard
>>
>>57420401
??
>>
did sussman larp?
>>
>>57420395
i don't think scheme is typically compiled.. i'm sure some are out there though
>>
>>57420408
So? You'd have an argument if it was actually faster to develop with them, but it's not.

>>57420155
How can you possibly inspect variable values at a breakpoint without
A. dumping all of them or
B. painstakingly outlining each variable you want to inspect in your debugger

>official support is useless
nah
>>
>>57419998
everything you described is available in emacs though (magit, elpa, gdb, etc.) aside from official support, and has objective upsides (e.g. working seamlessly in tramp-mode, being able to extend editor functionality without hacky plugins, etc)
also your attack on "git bash" is beyond retarded
>>
>>57420489
In gdb you just do "print <variable name>". You can also make a script that gets run when a breakpoint is encountered so you don't have to do it manually.
>>
>>57420489
it's faster to develop with a powerful enough text editor you're proficient in that any IDE in the world
>>
>>57420296
like do i focus on math or what
>>
>>57420536
what are your goals
>>
>>57419995
Learn Haskell and watch the job offers roll in
>>
>>57420489
>How can you possibly inspect variable values at a breakpoint without
Debuggers can read compilers debug formats (like DWARF and CodeView) so it understands all your variables and functions just fine.
>>
File: error.png (12KB, 499x234px) Image search: [Google]
error.png
12KB, 499x234px
>>57419158
When I tried this it gave me this error.

What do I do?

Sorry about all this, I'm an idiot trying to learn.
>>
>>57420580
Like I said, go to the constructor of PackOfCrisps. Should be something like
 public PackOfCrisps(something something, somethingelse somethingelse) 
. Those types are what needs to go inside the parameters where the new object is created.
>>
>>57420577
>>57420518
Hey that's breddy neato
I still prefer IDEs for the other reasons stated

>>57420531
An IDE literally is a "powerful enough text editor", once you get to that level of obscurity they're one and the same. A "powerful enough text editor" would have 0 edge over an IDE because it'd be just as large and nonportable.
>>
>>57420569
maybe write a game or something? I didnt really have any

>>57420574
haskell is actually used?
>>
File: image.png (137KB, 1366x768px) Image search: [Google]
image.png
137KB, 1366x768px
def horizontal(n):
horizontal = (' --- ' * n)
print(horizontal)

def vertical(n):
vertical =('| |' * n)
print(vertical)

def board(n):
for i in range(n):
horizontal(n)
vertical(n)
horizontal(n)


working on tic tac toe. Day four of coding. I gave up on this bull cow game for briefly because game seems to broken and I can't figure out how to check user input no duplicate digits ;-;

I made this algorithm >>57418730

but it can only track the duplicates in a row. user can still input say 2428 and won't detect it.
>>
Trying to pass an unknown amount of arguments to a function in python. The function takes (*args) and the arguments themselves are stored in a list.

If I call
function(list[1], list[2])

the function runs fine, but as the final index could be different every time, I thought
function(list[1:])

would work. It returns
AttributeError: 'list' object has no attribute 'rfind'
so I played around and saw that calling list[1], list[2] returns a tuple rather than a list, yet calling list[1:] returns a list, so I tried calling the function with
function(tuple(list[1:]))

which returns the same AttributeError but for tuples.

Any ideas?
>>
does anyone know whether or not it's possible to create a function with a return type of an array of a length based on one of the arguments? in c++
>>
>>57420600
>>An IDE literally is a "powerful enough text editor", once you get to that level of obscurity they're one and the same. A "powerful enough text editor" would have 0 edge over an IDE because it'd be just as large and nonportable.
holy shit I can't believe you're this obtuse
I used the example earlier of emacs. an emacs setup can become as "large and nonportable" as an ide, but it gets that way only by containing only the extensions that you explicitly wrote or chose to install, and no more
then, from that point, it allows you any further extensibility you desire, and the whole thing can be debugged/examined at any point because it's just lisp
what ide are you using that this experience is replicated in
>>
>>57420641
Write
function(*list[1:])
>>
>>57420721
Thanks! I had come up with a workaround with
 for i in list[2:]:
function(i)

but that's far better.
>>
>>57420664
You mean based off, as in, the size is mathematically based off of the size of an argument? You can use strlen to obtain the size of an argument and pass that into your function someway. If you're just asking whether you can base the decision off of it, you can loop through the argument vector and use simple conditions to decide which argument you pass into your function which returns the new array.

Syntax for getting the argument count and *array respectively

int main(int argc, char **argv);
.
>>
>>57420824
thanks, but i'm thinking along these lines
template <size_t T>
array<int, T> func(T) {
array<int, T> a = { { 0 } };
return a;
}


i'd like this function to take an integer T and return an array filled with 0s of size T, but i'm getting "variable templates are not supported in this release"
>>
>>57421014
1) what's the unused param for?
2) won't work if T is a runtime variable
3) try just {}
>>
>>57416582
>not using prt sc to capture screen
>>
Alright /g/, I confess. I'm a bad programmer. I'm coding Conway's game of life in JS and I can't for the life of me figure out why this doesn't work. When I place a single cell on the grid it freaks out and makes diagonal lines everywhere. This is the function I'm running on a set interval. Please, if you can spot the bug, let me know.

var newState = window.gameState.slice();
for(var i = 0; i < 30; i++){
for(var j = 0; j < 30; j++){
var total = 0;

for(var k = -1; k < 2; k++){
for(var l = -1; l < 2; l++){
total += newState[(i + k + 30) % 30][(j + l + 30) % 30];
}
}

if(newState[i][j] == 0){
if(total == 3){
newState[i][j] = 1;
document.getElementById(i + "-" + j).className = "alive";
}
}else{
if(total < 3 || total > 5){
newState[i][j] = 0;
document.getElementById(i + "-" + j).className = "dead";
}
}
}
}
window.gameState = newState.slice();
>>
File: 1369070356619.jpg (399KB, 800x800px) Image search: [Google]
1369070356619.jpg
399KB, 800x800px
To waste one of the last posts before bump limit, can I ask whether I did FizzBuzz right?

fizzBuzzString = ''


for i in range(1, 101):
if i%3 == 0:
fizzBuzzString += 'Fizz'
if i%5 == 0: fizzBuzzString += 'Buzz '
else: fizzBuzzString +=' '
continue
if i%5 == 0: fizzBuzzString += 'Buzz '
else: fizzBuzzString += (str(i) + ' ')

print(fizzBuzzString)

Ignore the fact that it's Python and the use of strings. I just want to know whether the underlying logic (putting the test for i%5 twice in there as is) is the best way to go about FizzBuzz.
>>
>>57421213
No
>>
>>57421213
no

/thread

>>57421367
>>57421367
>>57421367
>>
File: 1422311482407.jpg (129KB, 1024x721px) Image search: [Google]
1422311482407.jpg
129KB, 1024x721px
>>57421287
>>57421370
Well, fuck. I thought I could make it run faster by eliminating the third test; whether i was indivisible by both 3 and 5.
Cheers but I had my hopes up on that one.
>>
>>57421213
yes anon, good job :3
>>
File: 2016-11-02_19-56-39-1.webm (330KB, 800x480px) Image search: [Google]
2016-11-02_19-56-39-1.webm
330KB, 800x480px
>>57421213
[ Fizzbuzz intensifies ]
>>
>>57421213
That is retarded
>>
Is there any way to nicely line up columns of formatted shit when using fprintf in C?
>>
Man
I'm having a shitload of fun in VR
have some portals (which are WAY fucking harder to deal with in VR than they otherwise would be)
https://my.mixtape.moe/gmejek.webm
>>
>>57419593
for books check this site:
http://gen.lib.rus.ec/

i recommend these:
the tcp/ip guide - description of network (not just tcp/ip) protocols and their interaction
design of unix os - kernel
knuth's taocp - algorithms and data structures
essentials of programming languages - implementing and designing langs
on lisp - macros (in context of common lisp, but easily ported to other lisps)
paradigms of ai, case studies in common lisp - you don't need lisp for this one, just examples are in it
concrete mathematics - most of the math you will ever need in cs

>>57419677
most schemes define up to 5 levels, but defining a macro which let's you stack them arbitrarily is possible

>>57419967
i will have to start using it someday, i always forget it even exists -.-

>>57420395
chicken, compiles to c and is very optimized. also has very good ffi.

when you get tired of having to implement everything by hand check out racket.

>>57420602
yes, haskell is actually used. maybe you heard of GHC, it's implemented mostly in haskell
>>
>>57421959
Use tabs. "\t"
Thread posts: 309
Thread images: 24


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

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


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