[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: 34
File: daily programming thread2.webm (2 MB, 600x338) Image search: [Google]
daily programming thread2.webm
2 MB, 600x338
old thread: >>53757374

What are you working on, /g/?
>>
>>53764151
KILL YOURSELF DUMB ASS FAG
>>
I recently looked into design patterns and most of them are just to compensate for missing Java language features. Are design patterns a meme?
>>
>>53764173
Calm down bud
>>
>>53764151
I love this meme.
>>
What's the best way to merge the dev branch into master?
>>
>>53764302
-f
>>
>>53764151
what does anime have to do with programming?
>>
>>53764302
there are more than one?
>>
>>53764315
>git merge
>git rebase
>git merge -squash
>>
anyone know where I could pick up a risc machine cheaply? Preferably some kind of laptop

and ARM netbook or something?
>>
File: hime c.png (1 MB, 1280x720) Image search: [Google]
hime c.png
1 MB, 1280x720
>>53764311
anime and programming go hand in hand
>>
>>53764151
>mfw reddit == 4chan
https://www.reddit.com/r/MachineLearning/comments/4cf7k3/what_are_you_working_on/
Stop stealing thread ideas from Reddit. They even have a sticky stupid questions thread in the sub
>>
>>53764608
kill yourself FAG
>>
>>53764617
>leddit
>original
ayyy lmao
>>
File: 1348340537722.png (568 KB, 824x776) Image search: [Google]
1348340537722.png
568 KB, 824x776
>>53764151
image processing library for obstacle avoidance
>SAM3U
>>
>>53764617
kill yourself and fuck off back to l'eddit
>>
>>53764518
for what purpose?
>>
>>53764733
I want to write risc assembly because x86 is basically the C++ of architectures

and fuck using a vm
>>
What do I call a random number generator that answer the same results for given numbers?
I've made a simple prototype but I'm interested on looking at other implementations.

Something like this
foo = Random(someSeed);
foo.random(someValue) //0.3566878461
foo.random(otherValue) //0.843154816
foo.random(someValue) //0.3566878461
foo.random(otherValue) //0.843154816
bar = Random(otherSeed);
bar.random(someValue) //0.9547133546
bar.random(otherValue) //0.224899821
bar.random(someValue) //0.9547133546
bar.random(otherValue) //0.224899821
>>
>>53764774
youre trying to store generated values?
have to store result somewhere
>dynamic arrays
>>
>>53764774
A hash function?
>>
>>53764804
Nope, it's just some math tricks with mod and multiply by some big primes that give you always the same "random" numbers when you give the same input.

>>53764824
Hmmm... Yeah, I think so, didn't thought that way. Do they do hash functions with seeds? Lemme google it.
>>
>>53764849
I could be wrong but you would need to store the seed value of the first fetch if you want to get the same number out of the function.
>>
>>53764774
stateless
>>
>>53764849
alternatively, broken
>>
>>53764876
Exactly.

>>53764926
Yeah, it's certainly not secure, if that's what you mean. I'm not trying to encrypt things, just trying to generate some pretty images.
>>
>>53764962
then xorshift is probably the way to go

or you could take whatever you have now and feed it back into itself
>>
Can someone give me an example of how to get input for a simple text processor? Its for an assignment and I'm lost as fuck on how to get the input so I can run my functions correctly. For instance if i wanted to have three commands for adding spaces(addspace), making uppercase(upper), putting dashes in between each word(dashes), and then running it(run). It would look like

Please enter string and commands
>User's string
>addspace
>dashes
>upper
>run

And then the output would do those things to the user's string. Again, I'm looking for an example of how I would write the code to take input for each of those commands in a way that the user can simply type one and press enter and type another and it will call the functions, but not until run is entered.
>>
>>53764970
Oh, thank you, I suppose xorshift is the thing I'm doing on my code, by the looks of it. I simply didn't know the term. It seems like "stateless xorshift" is what i need to search for.
>>
File: output2.webm (1 MB, 640x480) Image search: [Google]
output2.webm
1 MB, 640x480
Rate my torus!

It's made entirely of spheres!
>>
>>53765005
The language is C++ sorry
>>
>>53765028
>It's made entirely of spheres!
l2blender fgt
>>
>>53764178
It was made with C++ (or smalltalk I guess) in mind

It was also around the time when OOP was shitting the bed, most good languages have abandoned java/c++ OOP in favor of proper design. You won't find abstract factories in Go
>>
>>53765040
>C++
I'm sorry too
>>
>>53765042
this is opengl
>>
>>53760883
#include <iostream>
#include <string>
#include <fstream>

int main(void)
{
std::string line, total;
std::fstream ifs;
int line_number = 0;

ifs.open("PATH\student.txt", std::fstream::ios_base::in);
if(!ifs) {
std::cout << "Couldn't open file for reading.\n";
}

while(getline(ifs, line, '\n')) {
if((line_number % 2) != 0) {
total.append(line + "\n");
}
else {
total.append(line);
}
line_number++;
}

std::ofstream ofs("PATH\formatted.txt");
ofs << total;

ifs.close();
ofs.close();

return 0;
}

They call me l33t terrorist because I have multiple targets.
>>
>>53763171
See: >>53765235
>>
>>53764617
You are being a mouth-breathing newfag.
>>
>>53764311
Programming appears at about the same rate as western televesion. I'm not quite sure what you're complaining about.
>>
>>53765155
make a proper torus model in blender and render it in opengl
>>
>Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

R8 my FizzBuzz, /g/
#include <stdio.h>

int main() {
int n;
for(n = 1; n <= 100; n++)
switch((n % 3 == 0) | (n % 5 == 0) << 1) {
case 0: printf("%d\n", n); break;
case 1: puts("Fizz"); break;
case 2: puts("Buzz"); break;
case 3: puts("FizzBuzz"); break;
}
return 0;
}
>>
Hey can I ask you guys about my php problems? /wdg/ is full of
>>>>>>>>web designers
>>
>>53766212
Give it a shot.
>>
File: 1457186802354.jpg (410 KB, 876x2350) Image search: [Google]
1457186802354.jpg
410 KB, 876x2350
>>53766212
Yes
>>
>>53766228
It's really regarding XML

I've got a node in there which if one is set, needs to disable the rest. for example
<nodes> 
<node>
<name>NodeOne</name>
<unique>false</unique>
</node>
<node>
<name>NodeTwo</name>
<unique>false</unique>
</node>
</nodes>


How would you approach this?

Right now I've got in pseudo
if(nextNode.unique == true){
for each (node in .xml file){
set unique false
}
}


Next node being what the user's sent to me before being saved in the xml.

But my problem is if the user wants to go back and select another node as unique, I've no plan for that.

Sorry if I'm a fucking idiot I'm just a hobbyist and this is bothering me.
>>
>>53766329
before you Xperts get to me i understand
nextnode.unique == true is redundant.
>>
File: 2016-03-30_06-28-27.webm (660 KB, 478x246) Image search: [Google]
2016-03-30_06-28-27.webm
660 KB, 478x246
ANOTHER QUALITY PRODUCT BY ORACLE

WHEN I CHANGE THIS ONE FUCKING NUMBER THE PROGRAM CRASHES

I CAN DO ANYTHING EXCEPT CHANGE THIS NUMBER

YES, I MAD
>>
>>53766329
1. Store your XML data in data structures in your language
2. Use and manipulate data within the language, serialize back to XML when done
3. ????
4. PROFIT!
>>
>>53764617
Retard, reddit stole it from us.
>>
>>53764774
Pseudo RNG?
>>
>>53764634
>>53764704
>>53765699
>>53766558
>being so ez
>calls others new
kek
>>
>>53766585
>i-i was just pretending to be retard! i swear!
>>
>>53766329
I don't really follow you senpai. What's the problem?
>>
File: 1459288469403.jpg (85 KB, 641x626) Image search: [Google]
1459288469403.jpg
85 KB, 641x626
>>53765816
>switch()
>>
>>53766451
Oracle is run my sales people
>>
Everything is run by sales people. Developers are nothing but replacable proletariat
>>
if hasattr(obj, 'foo'):
obj.foo

or
try:
obj.foo
except AttributeError:
pass
>>
>>53764178
>Are design patterns a meme?

Most of them are shit. Most architectural patterns are shit, too.

Everyone uses MVC. Know that and forget everything else.
>>
File: w5IQaHB.png (4 KB, 473x100) Image search: [Google]
w5IQaHB.png
4 KB, 473x100
>>53766451
I HAVE DEFEATED WORKBENCH'S FAGGOTRY WITH THE POWER OF MATH
>>
>>53764178

using a design pattern = repeating code
>>
Why is it programming general turned to shit when weaboos started appearing here on /g/?
Back then i actually learned something now its just nothing.
Good job weabshits you scared away the real programmers.
>>
File: 1457924692287.jpg (688 KB, 975x1789) Image search: [Google]
1457924692287.jpg
688 KB, 975x1789
>>53767080
>when weaboos started appearing here on /g/?
Fucking idiot. Weaboos have been here the entire time. It's a fucking weeaboo website.
>>
>>53767080
Weeaboos have always been here.

4chan IS weeaboo.

The problems happen when normies venture out of /b/ and /v/ and complain about the site culture, which has always been anime-oriented.
>>
>>53766592
you gotta realize you can't just quote this shit every time you don't get somebody's obvious sarcasm and think you can get away with it. You've been found out - everybody knows you're stupid now.
>>
>>53767080
>when weaboos started appearing here on /g/
Fuck off newfag
>>
>>53765816
Nice, I like this one.
>>
>>53767234
Tone of voice isn't conveyed through the internet, and with the constant cross-contamination, it's perfectly believable that some retard could think reddit started that.

Plus, we all have autism, so you need to stop speaking in riddles. It's hard for us to understand non-literal statements.

Unless this is how you get your kicks on a Wednesday. If so, carry on.
>>
>>53767234
epic ruse mate you got us good
>>
File: ss.png (33 KB, 734x114) Image search: [Google]
ss.png
33 KB, 734x114
What's the point of these slashes?
>>
>>53767532
so you can spread the macro across few lines for readibility
>>
>>53767532
The inverse of '\n'
>>
Is this a good place to talk about programming language design? Does anyone here have experience designing programming languages? Would there be interest in a dedicated thread on the subject?
>>
VIm or nano?
>>
>>53767658
Don't need any more generals, here is fine.
>>
File: 1459205440054.jpg (16 KB, 468x358) Image search: [Google]
1459205440054.jpg
16 KB, 468x358
>>53764151
>that webm
>>
>>53767678
Alright, thanks for stopping me. I'm new to /g/ anyway, I really should lurk more before suggesting a new general lmao.

My biggest problem in trying to design this language is twofold. First off, I'm never sure how much I should be doing from scratch and how much I should leave to implementation details- I'm never gonna do C better than C does C, and I want the new language to be pretty high-level, but how much do I rely on the implementation language before it starts to look like a relex? The second half of the problem is that I'm not implementing it in C (I don't know C), I'm doing it in Python. That makes it significantly more tempting to let the implementation language do the work for me, and therefore harder to produce something worth the effort I put into it.

Should I just learn C and implement it in that?
>>
>>53767803
learn hebrew
>>
>javascript
new Date


>python
import datetime
datetime.datetime.now()


LOL
>>
>>53767803
>I'm doing it in Python
anon...
>>
>>53767909
both are beyond disgusting
>>
I guess I could talk about what I'm trying to do with the language, too.
>no distinction between singleton values and arrays of length one- like Python's str, but for every type
>block-level lexical scopes are a basic datatype that is, by default, created and destroyed at the boundaries of the block, but can be stored in identifiers like any other kind of data
>>identifiers are just attributes of scopes
>>some identifiers can be designated as "unscoped," accessible without qualification in the defining scope and any child scope that doesn't explicitly get rid of them
>>there's a read-only (unless I think of a compelling reason to expose its innards to the programmer) "stack" of scopes whose first member is the current scope and whose last member is the outermost scope, such that moving from one scope into an inner one "pushes" and leaving an inner scope "pops"
>strong typing for functions, which always and only accept a single argument (but that argument may be a "composed" type wrapping together multiple values)
>aesthetically, most of the basic lexemes are one- or two-character ASCII strings; however, the language is intended to be permissive about encodings/character sets, and will assume UTF-8 for files without an encoding declaration

>>53767954
lmao right? I happen to like Python, but it's an extremely iffy choice for this task, especially given that I'm not that good at this. It is, however, the only language I'm even remotely fluent in, so I'm kinda stuck if I'm not willing to invest in learning a new language
>>
>>53767909
>javascript
var dicks = "1";
dicks += 1;
console.log(dicks); // 1


python
dicks = "1"
dicks += 1 // type error
print(dicks)
[/end]

LOL
>>
File: heh.jpg (60 KB, 550x370) Image search: [Google]
heh.jpg
60 KB, 550x370
>>53768124
Think that's bad?
>>
>>53768124
> jasavscript

typeof {} // "object"
{}.lol // undefined
typeof null // "object"
null.lol // TypeError
>>
File: 1373246182599.jpg (264 KB, 1024x807) Image search: [Google]
1373246182599.jpg
264 KB, 1024x807
>>53768124
>type error
>at runtime
>>
>>53768147
I'm too lazy. Is it symmetric?
>>
>>53768174
yes
>>
>>53768147
>javascript
>comparing with ==
>ever

You're the retarded one.
Do a "typeof NaN" in your console if you want to laugh
>>
>>53768199
>typeof NaN
>"number"

lol
>>
>>53768183
At least there's that, but oh my god! i'd rather do some hardcore mental calculus, at least it's logical.

Can any of you bitwise-xor numbers in your head? Do you know the [0-16[ table by heart?
>>
>>53768199
That's PHP. Wanna revisit your "retarded" comment?
>>
>>53768156
It's not that illogical tho: If, like >>53768199 pointed out, the absence of a number is still of type number, then the absence of an object can still be an object, just like in quite a lot of languages with objects (Java for example). The fact that it is classified as TypeError is nonsense tho. Also:
js> +{}
NaN
js> +null
0


But yes, type means nothing in Javascript. Also, >>53768199 you dummass, notice that I haven't used == and yet we're still in it.
>>
>>53768238
My bad then. I abandonned PHP years ago.
Most backend jobs today are in php though.
>>
>>53767014
top qeq
>>
>>53767014
It's actually sad that you had to do this.
>>
File: thetruthaboutjs.jpg (103 KB, 1024x576) Image search: [Google]
thetruthaboutjs.jpg
103 KB, 1024x576
>>53768313
js> +[]
0
js> +[1]
1
js> +[1,2]
NaN

Aww shit. And the result of that crap is that JS “programmers” spend their time trying to not write code that casts stuff AFAIK, whereas some sensible casting rules could be taken advantage of IMHO.

Anyone has seen a case where implicitely casting a value to absolute meaningless shit solves a problem elegantly?

love that pic.
>>
>>53768124
Are you fucking retarded?
> a = "1"
"1"
> a += 1
"11"


Which is 100% reasonable for a weakly typed language.
>>
>>53768183
And is it transitive?
>>
I'm looking at the Wikipedia page on closures, and my brain's wrinkling.
function startAt(x)
function incrementBy(y)
return x + y
return incrementBy

variable closure1 = startAt(1)
variable closure2 = startAt(5)

so... when you call closure1 and pass it z... it returns z + 1, but when you call closure2 and pass it z it returns z + 5? I guess? none of the use cases on the wiki page help me get why this is useful.
>>
>>53768439
Ok, so string takes precedence over number in deciding whether plussing two values adds or concatenates, who would have guessed? And what if you're doing
n = 1; n+=something that may turn out to be a string;
is there really no room for surprise when n suddenly becomes a string? Variables do have type sometimes dammit, and TypeError would certainly be the best behavior for plussing two mismatched values.

And then we end up defensively casting, just like in a strong and statically typed lang, only worse.
>>
>>53768519
Non-repetition? The alternative would be
function closure1(y)
return y+1
function closure2(y)
return y+5

Even that is enough justification, we are abstracting a common pattern here (well, not so common, but there are better examples surely). And closures have a lot of other uses, it's just that Wikipedia doesn't list them maybe.

>my brain's wrinkling.
wrinkles are the seat of wisdom in every meaning. Besides, I assume you've got the basic idea of what closures are, we'll show you some useful applications here, don't worry.
>>
>>53767014
I'm willing to bet 50 dollarydoos it doesn't optimise that out, either.
>>
>>53768519
you can think of closures as a function operating on a struct (or object), where the function operated on that struct (a method) and the state in that struct is defined by the variables you're using in that closure

closures and objects are interchangable. objects are more explicit, while closures are easier to define than objects.
when you need to use the same state in multiple places, it makes sense to use an object over a closure.
>>
>>53767147
>He thinks everyone who browses 4chan loves weebshit

wew lad
>>
>>53768570
Sorry, deceptive wording- I'm sure closures ARE useful. I'm not rejecting the concept, I'm just not getting it. Examples that duplicate basic features of the language aren't very illustrative for me? (They seem to be for other people, I'm not dissing that approach, it just doesn't work for me.) Obviously there are things that are done better with closures than without, but adding numbers isn't one of them- even if the closure implementation was more efficient in one sense, the opacity penalty is pretty damning- and I have trouble seeing the concept for the example, you feel.

>>53768677
okay, that's part of the issue then- I was wondering why one wouldn't just write a class. Writing a closure is cheap (in brainpower, at least), writing a class is more expressive, different problems are easier to tackle depending on which of those factors is important. am I getting it?
>>
>>53764151
>What are you working on, /g/?
Pic related
>>
>>53768523
I'm not saying the behavior is ideal or even acceptable, I was just pointing out that your example was wrong. "1" + 1 is not "1", it's "11".
>>
>>53768718
> your example
>>53768124 wasn't me. You're right tho, the guy probably fucked up the copypasting. What do you thing about defensive casting, tho?
>>
im a first year cs student should i continue to bother with java? i like to think im alright at it even though im still learning.
>>
>>53765816
Nice, but it doesn't work.
I like though, it it's really...compact
>>
>>53768709
yeah, kind of
there's that saying that closures are just poor man's objects and objects are just poor man's closures
keep in mind most features in languages are duplicates that just work slightly differently but are just more convenient in certain situations
you use a closure when you'd otherwise use an object with a single method.
sometimes, when you're only using a single method and encapsulating the same state in a lot of places, then using an object to express that similarity is the way to go
>>
>>53764151
>webm

I'm not sure I understand the editor's note. What does order have to with anything when packing a struct? Assuming a stable ABI, the order will be the same regardless of how it's stored. What am I missing here?
>>
>2016
>Not programming in Java

What's your meme reasons which is not a real reason because you are not a real programmer unless you program in big cock Java
>>
>>53768940
https://wiki.theory.org/YourLanguageSucks#Java_sucks_because
>>
>>53768940
Because >>53768717
>>
>>53768796
Java is fairly marketable, and because you have an introduction, it'll be easier for you to continue to do more complicated things.
>>
>>53768973
https://wiki.theory.org/YourLanguageSucks#Python_sucks_because
>The main function construct is awful and probably the worst I have ever seen
lmaooooo I thought I was the only one, I've NEVER heard anyone mention this but it's so bad
>>
>>53769054
It's completely optional unless you're making a runnable module.
>>
File: fizzbuzz.png (61 KB, 1600x900) Image search: [Google]
fizzbuzz.png
61 KB, 1600x900
>>53768838
Breaking news: it does. What made you think it didnt? (God, make it so that I didn't just miss out on something really obvious)
Also
else if
is wrong and harmful. I'm writing a meme article on it, you'll hear about it soon.
>>
>>53769077
It certainly doesn't stop me from using Python, but it's entrenched in the idioms and it's ugly af. I thought I was crazy because I've never heard anyone acknowledge how bizarre it is. My dad's a bit of a Python bigwig so all the programmers I know are Python fanboys, I know there IS criticism of Python but I'm unusually well-insulated from it
>>
File: haskell-hnreddit-shills.png (260 KB, 600x800) Image search: [Google]
haskell-hnreddit-shills.png
260 KB, 600x800
>>53769013
>>
>>53769171
You have a cool dad, anon.
>>
Is bash allowed here?

>implying only c++ is allowed

Anyways. I am using using printf to give me verbose progress in my script.

ArrayWorkAround="In Progress... Success! Completed! Failed!"

printf "Task Progress :. \033[1;33m ${ArrayWorkAround:0:14} \e[m .:\r"

The reason for the code is because I am doing this on busybox ash (openwrt)

I currently am using two of those print lines, one to say in progress, and another one to say success!, is there a way I can use one printf, and somehow change in progress to success or fail or whatever?

My desired outcome is something like this
printf "Task Progress :. \033[1;33m In Progress... \e[m .:\r"


then once the task is done it updates to this:
printf "Task Progress :. \033[1;33m Success! \e[m .:\r"


Is it possible? Would I need to use boolean of some sort?
>>
I've just finished GUIs in >Java
I am now officially done with this language as far as I'm concerned.
Should I learn C, C# or C++ next?
>>
>>53769206
I kinda do, he worked in the same lab with Guido for a while. We went to a meetup and my dad got a special introduction- he wasn't an invited guest or anything, but the dude was really impressed with my dad. Up until that point I didn't realize that in his own little world he's kind of important lmao
(I'm crossing my fingers that employers a) know who he is and b) assume I inherited the skills, I don't have much else going for me in the employability department)
>>
>>53769279
>Knows Java
>Doesn't know C
What the flying fuck?
>>
>>53769279
>implying C is the same as C# and C++

and yet you think you're done with java?

I will let you google difference on C vs C#, C++ before replying back so you can act like you know the difference.
>>
>>53769279
C if you want to learn lower-level concepts.

C++ if you want a little lower-level, but with lots of libraries to still work with.

C# if you want familiarity without a good chunk of what makes Java annoying to program in. Do C# if you want to make more GUI stuff.
>>
>>53769291
You don't want to get a job through nepotism m8.

Even if you do eventually get the skills to justify your position, you'll always be "X's son"
>>
>>53769279
There's like QT and GTK bindings libraries for like higher level braindead langs anon.
>>
>>53769317
I was told it was babby's first language to learn the rules of programming.
>>
>>53769317
not that guy but my alma mater taught the intro courses in Java. I don't know WHY but it happened

>>53769341
I'm joking mostly. You know from firsthand experience, or have you just worked with X's son for some value of X?
>>
>>53769348
You were lied to, anon.
>>
>>53769348
>java
>good for beginners
Whoever told you that should kill himself.
>>53769355
Meanwhile, at a decent school (MIT), they start with Python.
>>
>>53769348
Java and C# both fit the bill here.

Strong, static typing helps newbies understand the concept of casting and typing in general.
>>
how do I learn Scheme without using emacs? I'd suck it up and use emacs but I need those brain cells to breathe and keep my heart beating
>>
>>53769317
>Java users being completely clueless when it comes to C

How is this at all surprising?

>>53769332
Where did he imply the languages were the same?
Are you watching this thread through text-to-speech?

>>53769355
It's never good trying to live up to someone else's name.
You'll either never be as good and get shit for it, or be just as good but nobody will believe it and still get shit for it.
>>
>>53769199
is scala really that bad? i just got an internship with a company that uses it and java
>>
>>53769396
Uh, use racket?
>>
>>53764151

Hey guys new python programmer, this code is for a slot machine. The bank starts at $10, if the first deal is equal to the second deal or third deal, $2 is added to the bank, and you can read the rest of the code and it'll make sense in your head. For some reason, no matter the cirumstances of the random hands it always adds $2 the bank and I just don't understand the issues or why this code doesn't just want to work.


from random import randint
bank = 10
print("Bank is $10")
hand = 'HSBDX'
while bank > 0 or bank < 20:
deal1 = hand[randint(0,4)]
deal2 = hand[randint(0,4)]
deal3 = hand[randint(0,4)]
if deal1 == deal2 or deal3:
bank = bank + 2
elif deal1 == deal2 and deal3:
bank = bank + 5
elif deal1 != deal2 and deal3:
bank = bank - 2
print(deal1,"--",deal2,"--",deal3,"--->Bank is $",bank)
if bank >= 20:
print("You win!")
break
if bank <= 0:
print("Try again.")
break
input()
>>
>>53769396
Emacs and Scheme aren't bound together, Emacs uses Emacs Lisp (or Elisp), which is different from Scheme. I'd advise you go for Racket and DrRacket, they emulate SICP Scheme out-of-the-box.
>>
>>53769396
dr racket
>>
>>53769417
>or deal3
>>
>>53769417
deal1 == deal2 or deal3
doesn't do what you mean.
>>
>>53769417
Yep, or and and are for booleans (True or False, results of comparisons), but if you use a non-boolean in them, everything besides None becomes True, so
... or deal3
can be True anytime deal3 is truish, and any string will do in this case.
>>

def exercises(r,c):
mat = """7283455864
6731158619
8988242643
3830589324
2229505813
5633845374
6473530293
7053106601
0834282956
4607924137"""
pr = 3
pc = 4 #pattern's collums and rows
total = 0;
pattern = """9505
3845
3530""";
found = False;

while(found != True):
for i in range(0,r):
for j in range(0, c):
if mat[i*10+j] == pattern[0]:
fromStart = j
fromEnd = j+pc
total = 0
for k in range(i, i + pr):
for l in range(fromStart, fromEnd):
if mat[k*10+l] == pattern[k-i*3+l-fromStart]:
total += 1
print total;
found = True

exercises(10,10)



I'm a special kind of retard
>>
>>53769418
>>53769415
>>53769421
I had a similar strong negative reaction to the Racket IDE as I did to emacs, but I'll plunge in again. I didn't recognize SICP Scheme as being core Scheme when I looked at the options, my bad. And I know that emacs and Scheme aren't technically married, but it's a little surreal to look for non-emacs setups- there's Dr Racket, somebody's pet Windows IDE (I'm using Ubuntu), an Eclipse plugin, and that's it.
>>
>>53769406
One of those languages is not like the other.

>Hurr C must be the same since it uses the same letter as C#, and C++

Remind me of this stupid black bitch thinking bluetooth and bluray were the same, even though she was a "expert in technology field" Because both words were pronounce with blue in it.
>>
>>53769510
>wanting an IDE
>>
>>53769511
Dude what are you on about? I just want to learn another language and want to know which one should be first. I'll probably learn them all eventually. Programming is a hobby, not a career for me.
>>
>>53769534
oh, sorry, forgot my
>#tw: I'm a little bitch baby who uses IDEs
, it won't happen again boss
>>
File: emacslogo.png (32 KB, 302x260) Image search: [Google]
emacslogo.png
32 KB, 302x260
>>53769534
Emacs is an IDE, it's just also a religion, life, the universe and everything. Also I remember now that core scheme is a bit bizarre. If you want to do sicp (which you haven't confirmed btw), try installing this: http://docs.racket-lang.org/sicp-manual/index.html
>>
>>53769511
>What's better, apples or orange?
>HURRR OMG HE THINKS APPLES AND ORANGE ARE THE SAME FRUIT xD

Re-read the fucking post you mong.
>>
>>53769578
that looks like arabic
>>
>>53769555
>learn them all eventually

As long as you don't wear fedora, fingerless gloves, and trenchcoat and randomly tell people you know 9 programming languages. Oh god, remember it vividly,

>working at college bookstore
>cringe neckbeard walks up
>throws greenfoot book on counter
>"yeah, I know 9 languages"
>No, you don't, you know how to say hello world in 9 languages.
>>
>>53769605
Yes, it's beautiful. I think it's more-or-less voluntary. (read the history behind that logo but forgot) Can you see the Sacred Gnu? It looks to the left, just like in Arabic. (took ME an explanation to finally see it)
>>
>>53769435
>Anonymous 03/30/16(Wed)09:14:40 No.53769489 ▶
>>53769445
>>53769489

Appreciate it fellas,
done and submitted :)
>>
>>53769578
SICP is fine I guess? I'm quickly gathering that "core Scheme" is not the clear-cut concept I thought it was, so I suppose I just pick a version and go with it. There doesn't seem to be a finished R7RS implementation in Racket's package index, unless I'm looking wrong. How painful is it to migrate between dialects/implementations of Scheme?
>>
>>53769396
https://www.gnu.org/software/mit-scheme/

i used this when i read SICP, it is derived from emacs and it looks like it but it's actually very simplified and a lot cleaner

it is an IDE
>>
>>53769672
>https://www.gnu.org/software/mit-scheme/
that's the exact one I bounced off of, lmao. But I also bounced off of Dr Racket, which I'm already planning to have another go at, so a re-try may be in order.
>>
>>53769667
>How painful is it to migrate between dialects/implementations of Scheme?
absolutely painless. I migrate from Elisp to Racket to Clojure daily. I'm accustomed to always looking things up in the doc though. What are you going to do first? Learn? With what? Might be useful for us to direct you on a first dialect. Then you become *-dialectal, and most dialects are libraries btw, scheme allows that.
>>
>>53768439
I meant to write 11 but fucked up (as you can probably guess by also fucked up code tags) but it's not reasonable at all.
>>
>>53769763
Learn, I suppose- I don't have a directed goal, Scheme just looks cool- and I'm not opposed to using SCIP if that's the kind of answer you're expecting for "with what". If transferring between dialects is simple, and I certainly am in the habit of checking docs, I'm pretty open. My first language is Python if that influences your answer, but I'm here to learn a new way to think, not write Pythonic Scheme, so I wouldn't weight it too heavily.
>>
#include <stdio.h>

int main(void) {

int s, m, h;
s = m = h = 0;

while(1) {
printf("%.2d:%.2d:%.2d\n", h, m, s);
s++;
if (s==60) {m++;s=0;}
if (m==60) {h++;m=0;}
if (h==24) {h=0;}
sleep(1);

return 0;
}


i a new to C
rate my counter program
>>
>>53769838
SICP is for non-programmer math majors tho, as I've understood, I don't know if this matches your profile. Transfering between dialects while checking the docs is even more interesting inside racket though, since it is designed to foster dialects and provides something like 5 of them out-of-the box. If you've done some Python, I'd recommend the Racket guide, which I've read parts of, it's nice. Also the Racket reference quicks ass IMHO, so using Racket is quite a bonus.

Did you use the REPL when you started with Python? I know I did, but I'm curious.
>>
>>53769913
A+
>>
>>53764178
A lot of them are useless when you can pass function as argument
>>
>>53769913
missing a }
>>
>>53769961
thanks buddy
>>53769983
oh
>>
>>53769913
Why do I get this when attempting to compile? implicit declaration of function 'sleep' is invalid in C99
>>
>>53770026
-std gnu89
>>
>>53770026
#include <unistd.h>


?? I'm not a C person.
>>
>>53769955
>non-programmer math majors
I'm a sorta-programmer linguistics major, if that's useful information, hahaha. Python and R are The Thing, so far as I can tell, when it comes to linguistics-related programming.
>Did you use the REPL when you started with Python? I know I did, but I'm curious.
no, actually, I played with the console for like two minutes and got bored. I have the kind of brain where I want to write The Whole Thing before checking that any particular part works, so using the interactive console got irritating fast. Honestly I should probably have stuck with it longer, "write as much as possible before running" is a terrible coding strategy. I do use it to check shit now, though.
>>
>>53770026
Need to include unistd.h
>>
>>53770079
>>53770053
Thanks, compiled.
>>
>>53770060
> "write as much as possible before running" is a terrible coding strategy. I do use it to check shit now, though.
looks like what I do.

> Python and R are The Thing, so far as I can tell, when it comes to linguistics-related programming.
Not the first time it gets posted, but this guy does not agree: https://github.com/panicz/pamphlet
It uses Guile Scheme, and I think he has a point. This won't increase your employability tho, quite the opposite. Red-pill stuff.
>>
Hey Java fags, how often do you use interfaces? What's their purpose in the grand scheme of OO design?
>>
>>53770154
so all interacting objects have the same functions without them needed to be inherited
>>
Native bash on windows linuxfags btfo
>>
>>53770140
The REPL has a quick "feedback circle time", it's almost like a conversation. It's great for first-time experience IMHO, and quick checking as you've said. A great tool which Java can't even begin to have (*wink* >>53768940)
>>
>>53770154
> What's their purpose in the grand scheme of OO design?
To avoid shoe-horning problems that don't exactly fit in the OO paradigm in a OO paradigm.
>>
>>53770209
And even the best essay-writers also have quick basic conversations daily.
>>
I'm going to go to chapters today and buy K&R. What should I expect?
>>
>>53770140
holy shit, polemics are maybe my favorite genre of non-fiction, thanks! Schemers seem like a fun bunch. Really my end-goal for learning Scheme is to be able to have edifying conversations with the kind of people who use Scheme, without seeing in absolute terms just how far the rabbit-hole goes.
>>
>>53770255
being out of date
>>
>>53770202
Why not target something better designed? Maybe dash (which is compatible with normal sh)?
Bash strikes me as the worst possible shell to target. You'll spend most of your time trying to emulate all its little quirks.
>>
>>53770275
I can just compile all my code with -ansi
>>
>>53770275
This. C has come a long way. K&R wont have all the improvements that many modern projects use. At a minimum, find a book that targets c99 (even those are out of date)
>>
File: 1458232096496.jpg (86 KB, 800x1119) Image search: [Google]
1458232096496.jpg
86 KB, 800x1119
Working on my file server with torrent support.
Currently migrating all commits from dev into master. The 2 branches idea didn't really work out the way I wanted. Next up is implementing removal support.
>>
File: magritte.jpg (100 KB, 1024x778) Image search: [Google]
magritte.jpg
100 KB, 1024x778
>>53770260
Programming is more that code, thank you for joining us programming literates.

Ask your beloved programming literate anything!

Daily reminder that every language besides LISP is a worthless glorified domain-specific language.
>>
>>53770450
>ily reminder that every language besides LISP is a worthless glorified domain-specific language.

Sup Charlie
>>
okay, this is the part where I reveal myself to be out of my depth: how do I add drracket to my path? I chose the non-Unix style installation on a whim and don't know how to make it runnable from anywhere, should I just reinstall or is there an easy way to do this? do I alias the path to the drracket file to, say, drracket in my bash.rc? help I'm painfully dependent on GUIs
>>
>>53770305
Its not emulate, its just native bash on windows
>>
>>53770360
Are you using libtorrent, or rolling your own torrent implementation?
>>
>>53770494
Change the PATH variable.
>>
>>53770494
export PATH=$PATH:*path to drracket*=


in your bash profile or bashrc
>>
>>53770494
only the shell prompt interprets aliases. Yes, try exporting the PATH variable. it will only affect processes that you launch from an context with the good PATH tho.
>>
>>53770512
Neither. It's not a torrent client itself, but it acts like a generic front end for torrent clients.
>>
>yeah, just add it to your path
>>
>>53770450
>worthless glorified domain-specific language
I think languages that are "domain-specific" and small, that do one thing well (like C and Erlang) are best t.bh

>Ask your beloved programming literate anything!
I've been wondering for a while now: why are there no anime-style Stallman drawings?
>>
>>53770545
Also install gentoo, it's genuinely easier on GNU/Linux for once.
>>
>>53770574
We need a lewd lucky star x Richard Stallman crossover
>>
http://mooc.cs.helsinki.fi/programming-part1/material-2013/week-2?noredirect=1

can anyone help me do exercise 39.2 (using only while loops). kinda stuck lads.
>>
>>53770597
it's not a penis it's a GNU/penis
>>
>>53770618
it doesn't say anything about while loops but anyway

int i = 0;
while (i < 5) {
; // do stuff
++i;
}

// for (int i = 0; i < 5; i++) { ; /* do stuff */ }
>>
>>53770530
this didn't work and I'm too much of a buffoon to guess why. Is there any reason the alias method won't work, provided I just run from the terminal consistently?

>>53770579
I'm on Ubuntu, is Ubuntu sufficiently gentoo?
>>
>>53770683
im guessing because we haven't learned about for loops yet.
>>
File: 1456401181293.webm (1 MB, 798x596) Image search: [Google]
1456401181293.webm
1 MB, 798x596
>>53770574
>I've been wondering for a while now: why are there no anime-style Stallman drawings?
Good point, it's surprising. He's a figure tho. Maybe he's beard isn't anime-friendly? Also, apart from Himegoto, I can think of no programming figures who've had this treatment.

Related: when anon wanted to do a VN on him (pic), he was told that the man was quick to sue for defamation. Is that true?

(Yes I know I'm the one who should be answering questions btw.)
>>
>>53770737
it literally wants you to repeat yourself and not use loops so it can say "hahaha use loops faggot we're so clever"
>>
>>53770760
Should've told Stallman that his likeness is open source
>>
File: racket.png (18 KB, 396x120) Image search: [Google]
racket.png
18 KB, 396x120
>>53770574
>I think languages that are "domain-specific" and small, that do one thing well (like C and Erlang) are best t.bh
And they're all alone in their separate worlds. A Lisp can bind together many DSLs, abstracting that dammned wheel, which is good for implementation effort and not-having-to-learn-everything-over-again, and making them more interoperable. Your turn.
>>
>>53770837
Lisp is slow as fuck
Use nim
>>
>>53770688
Is there a specific reason you're not using the deb package in the distro? I assume there is one right? Even Arch has it. It contains a graphical menu entry, and this will avoid having to clutter your path for no good reason.
>>
>>53770868
Not necessarily. Besides, Nim's syntax is god-awful. speed can be improved, syntax cannot. Checkm8
>>
Need to take a large line of data in a CSV and take someones name, turn it from 5 characters for example, down to three. I am thinking of doing this is in python but I am still learning. Any python pros out there that can lend a hand? It is 1400 row CSV file.
>>
>>53770883
this reason may be as stupid as everything else I've been doing the last few minutes, but I do have a reason this time: The installation instructions for the SCIP thing are version-specific and I couldn't figure out how to do it in the distro version, which is a main version number behind. The alias thing works for me, so far as I can tell.

>>53770944
do you know which entry the name is?
>>
>>53770908
>syntax cannot be improved
wrong

>speed can be improved
>lisp
wrong
>>
File: 3pnkbuj.jpg (32 KB, 720x405) Image search: [Google]
3pnkbuj.jpg
32 KB, 720x405
>>53770868
>Lisp is slow as fuck
>Use nim
Nim:                            6.083644424 seconds time elapsed
Common Lisp SBCL: 3.015000773 seconds time elapsed
Racket: 3.618877176 seconds time elapsed
Scheme Bigloo: 3.604533288 seconds time elapsed
Scheme Chicken: 7.966139806 seconds time elapsed
Scheme Gambit: 1.932229635 seconds time elapsed
>>
why when i add together floats, it gives me a 4 in the end?
>>
>>53770978
>>53770944
so, like, the implementation I'm thinking of is:
with open("your_file_here.csv", "r") as f:
names = []
for line in f:
line_list = line.split(",")
names.append(line_list[the entry number - 1][:3])
>>
>>53771017
Because you're adding 2 and 2.
>>
>>53770837
mate are you telling me that using lisp for everything is better than using a language designed for the job?
>>
>>53771043
Python has a csv module.
>>
>>53770978
>what is the package
"racket", what else?

I've got "installing sicp" done in one single minute with
raco pkg install sicp
with a Unixy installation. What are you doing seriously?
>>
>>53771014
this is bait
>>
>>53771091
Reference: http://docs.racket-lang.org/pkg/getting-started.html#%28part._installing-packages%29
and it seems to work perfectly.
Finish installing Racket first, obviously, raco is unavailable otherwise.
>>
>>53770992
>>syntax cannot be improved
>wrong
Denial at its peak. Are you going to say that
2+2 == 5
next?
>>
>>53770978
Firstly thank you and
It is the 5th header(column) of the CSV.
>>53771043
and thank you,
Right, something that takes a string that is 5 characters in length and changes it to 3 characters.
I guess what is throwing me off is that I am still learning and I am not familiar with these core functions/methods/classes. So I am pulling in a function from python's standard library called "line" that then takes data defined in the 'as f:' statement and splits it down to 3?
(yeesh I apologize for the turn of phrase, I need to read up more).
>>
>>53771162
>what are macros
>>
>No compelling projects to work on
Is this hell?
>>
>>53771162
#define 2 2.5
>>
>>53771071
oops. I'm embarrassed I never thought to check

>>53771091
>what is the package
I assume you thought the second part of my comment was related to the racket thing? I've got the SICP racket package installed already, through the Package Manager, because I'm super GUI-dependent and this time the GUI happens to work.

>>53771186
"with open("filename", "r") as f:" opens the file "filename" in read mode, and makes "f" point to the file object it creates. The "with" syntax is a good practice because when you exit the with block it closes the file, even if an exception is raised, without you having to do so explicitly.

When you loop through the file object, each line in the file is stored in your loop variable (line, in my example- it could be any valid identifier). Each line is a string. "split(<separator>)" is a string method that takes the separator argument- in this case, ",", a string containing only a comma- and creates a list whose elements are the sub-components of line if you split each line at the commas and leave out the commas. The "for <blank> in <file object>" syntax isn't a function- Python just knows to for-loop through files line-by-line, so far as I can tell. I've never paid much attention to the details.

Now you've got a list of such-and-such strings. You want the fifth one in the list, so you get that with index notation- line_list[4]. line_list[5] is a string, and strings- like most other sequences- support slice notation- [start:stop]. start, if omitted, defaults to 0 (the first item), and [:3] gives you the first three characters.

That all make sense?
>>
>>53771403
>line_list[5]
fuuuuck me. That should also be 4. Sequences are indexed from 0, so the 5th item has the index 4.
>>
File: firefox_2016-03-30_12-42-40.png (910 KB, 1138x1030) Image search: [Google]
firefox_2016-03-30_12-42-40.png
910 KB, 1138x1030
Microsoft dropping some really cool shit at /build/:

https://www.microsoft.com/cognitive-services/en-us/apis

https://dev.botframework.com/#/

https://www.captionbot.ai/

>Remote debugging for XBone
>Win32 software deployable to Windows Store
>Blind dude walking around, Cortana describing what she sees
>Augmented Reality stuff

Cool stuff even for non-.NET programmers, especially with their new public AI APIs
>>
>>53771403
>do you know which entry the name is?
Fug, I assumed this was related to Racket. In that case excuse me sir.
>>
File: the ai is real.png (97 KB, 696x716) Image search: [Google]
the ai is real.png
97 KB, 696x716
>>53771485

Thanks Microsoft
>>
is math.h ceil() costly to use?
>>
File: 1459361189072.png (457 KB, 549x511) Image search: [Google]
1459361189072.png
457 KB, 549x511
>>53771485
>>
File: 1439796814962.png (9 KB, 729x34) Image search: [Google]
1439796814962.png
9 KB, 729x34
Sqlite3 says you can't use binded parameters for table names, which means I have to use a format string.
But using a format string is insecure, how can I protect against SQL injections here?

Or, is there a better way of maintaining a whitelist? when a client creates a user account, in addition to inserting the user into the accounts table the server creates a new table with name USER_whitelist to hold the whitelist for that user, is this the wrong way to do it?
>>
>>53771504
np! I can't really be offended, I'm the dumbass who needs my hand held any time I have to use a command line. : P

>>53771186
a couple other things:
>There's apparently (>>53771071) a Python module called csv. If you're allowed to use it (Idk if this is a class project or whatever) you should- no point reinventing the wheel. The Python 2.7 docs are here:
>>https://docs.python.org/2/library/csv.html
>and the Python 3.5 docs:
>>https://docs.python.org/3/library/csv.html

>I don't remember a lot about the precise formatting conventions of .csv files. In particular, if spaces are allowed- and if there ARE spaces in your file- you might have to be careful. One easy thing to do would be to call line_list[4]'s .strip() method, with no arguments, which removes whitespace (e.g., spaces) from the string. (IIRC, if there's no whitespace it should do nothing at all- convenient if the formatting's inconsistent!) Then you can slice the stripped string. You could do this in one line:
>>line_list[4].strip()[:3]
>or you could space it out across a couple lines. The first one's harder to read IMO but it's a matter of personal style.
>Python 2 docs on the string methods:
>>https://docs.python.org/2/library/stdtypes.html#string-methods
>Python 3 docs on the same thing:
>>https://docs.python.org/3/library/stdtypes.html#string-methods

In general, the docs are your friend and so is Google. If my dumb ass had bothered to look up "python csv" like a year ago, I wouldn't be able to write code to harvest data from a csv off the top of my head, but I would be able to use the csv module, which is better all-around.
>>
>>53771648
Why are you programmatically creating tables?

I smell potentially bad database design here.
>>
File: I DON'T REALLY KNOW.jpg (22 KB, 523x523) Image search: [Google]
I DON'T REALLY KNOW.jpg
22 KB, 523x523
Working on Haskell server / client using UDP. Can someone tell me why doesn't this work?
The client sends the data (I checked the number of sent bytes, it matches), but the server just keeps running.

http://pastebin.com/F8dXtAVE

Pic unrelated for attention whoring
>>
>>53771673
>>53771648
>when a client creates a user account, in addition to inserting the user into the accounts table the server creates a new table with name USER_whitelist to hold the whitelist for that user, is this the wrong way to do it?

Whoops, I re-read your post.

Yes, this is absolutely the WRONG way to do it!

You should have a table for users, and a table for your whitelists.

Simply create a foreign key for the user in the whitelist table on those entries pertaining to that user.
>>
>>53771680
Work is a side effect
>>
File: the_cloud.png (41 KB, 740x236) Image search: [Google]
the_cloud.png
41 KB, 740x236
>>53771403
>The "with" syntax is a good practice because when you exit the with block it closes the file, even if an exception is raised, without you having to do so explicitly.
Awesome, thank you. That does make sense. it almost sounds like when you close a cursor connection in SQLite.

You made my shitty day of getting in a car crash 100x better. Thanks anon, and I'll save your post to Python Evernote. Have pic related as some win and thank you again.
>>
>>53771673
I am pretty new to databases I admit.
So programmatically creating tables is a bad thing?
If that's the case, how would you do it?
>>
>>53771661
>>53771186
oh, and- in case you didn't know- using a module is as easy as putting an "import <module name>" at the top of your file. You'll still have to look at the docs to see what's in there, of course. Some IDEs will suggest things if you type in "csv.", but the docs will generally have more information in a more readable format.
>>
>>53771619
relatively speaking, even the most expensive C operation is cost-free compared to the most inexpensive operation in python
>>
>>53771695
>Simply create a foreign key for the user in the whitelist table on those entries pertaining to that user.
Ah, okay makes sense.
Thanks.

Are there any good reads on good DB design?
>>
>>53764151
name of animu?
muh dick needs to know.
>>
>>53771719
nobody mentioned python
>>
>>53771753
boku no hime
>>
>>53771753
himegoto
the anime is really short and is really just a promotion for the manga, which recently ended and is 6 volumes
>>
>>53771709
You're welcome! Python makes text file/string operations pretty simple, once you know the basics. : )
>>
>>53771752
This site seems alright:
http://www.ntu.edu.sg/home/ehchua/programming/sql/relational_database_design.html

I'll see if I can find some of the books we used in college.

Basically, just research "Relational Database Design Fundamentals" in Google.

Pay close attention to the concept of "Third Normal Form(3NF)"

Each table is about things and nothing but those things.
Thread replies: 255
Thread images: 34

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.