[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: 315
Thread images: 48

File: goto considered monadic.png (21KB, 892x319px) Image search: [Google]
goto considered monadic.png
21KB, 892x319px
Previous Thread: >>55746223

What are you working on, /g/?
>>
File: s.jpg (59KB, 500x500px) Image search: [Google]
s.jpg
59KB, 500x500px
>>55754086
>>
why are comfy interpreted languages so goddamn slow ?
>>
>>55754228

That's the price of freedom.
>>
>>55754228
Because they're interpreted?
>>
>>55754228
speed isn't comforting
>>
File: interesting.png (27KB, 937x374px) Image search: [Google]
interesting.png
27KB, 937x374px
Just finding it interesting that Lisp and Scheme are still more popular than Haskell.
>>
File: (You).png (8KB, 661x265px) Image search: [Google]
(You).png
8KB, 661x265px
>>55754262
>Lisp Scheme Logo
>Logo

Fucking Lisp memers
>>
>>55754262
>Logo more popular than Haskell

Nice.
>>
File: TIOBE_INDEX.png (62KB, 1326x581px) Image search: [Google]
TIOBE_INDEX.png
62KB, 1326x581px
TIOBE Index for July 2016

Top 10
>>
File: recorded.webm (380KB, 773x354px) Image search: [Google]
recorded.webm
380KB, 773x354px
>>55754086
>What are you working on, /g/?
>>
>>55754086
I want to write a piece of shit hobby operating system just for the sake of better learning how they work, can I just use C or do I have to write some assembly no matter what? I'm not going to make a bootloader or anything.
>>
>>55754276

That's just how the results happened to end up on the TIOBE index. It's really just a indicator on how much people search for information and resources on said languages.
>>
To the guy who wanted to start with C in the previous thread, don't. Start with Python instead, thank me later.
>>
>>55754322
There is something deeply wrong with your SSD. Is it on a SATA-1 port or some shit?
>>
>>55754368
Encrypted partition (Twofish-256)
and ancient laptop with slow, throttled CPU

I should replace the thermal paste
>>
>>55754383
why do you have your partition encrypted?

you don't have something to hide, have you?
>>
>>55754343
What about Scheme?
>>
>>55754086
Thank you for not using a trap meme
>>
>>55754439

Scheme / Clisp have the advantage of simpler syntax and less fussing about with harder to understand concepts (Monads / Comonads are hard for programmers to pickup at first).

All of them will teach functional programming. The debate is which is "Better".
>>
>>55754228
>lack of type safety
>comfy
>>
>>55754439
Based. I prefer Racket to plain Scheme, though.
>>
>>55754548
And the answer is Haskell
>>
>>55754559
Interpreter =/= dynamically typed you mongoloid.
>>
File: 1456564141053.gif (2MB, 260x195px) Image search: [Google]
1456564141053.gif
2MB, 260x195px
>>55754321
>tfw hitting brick wall with learning c++
>welp, back to learning Java it is
>verbose, in-library 'method' (seriously fuck calling functions methods...)calls, I'm comin' back, baby
>>
>>55754593
>seriously fuck calling functions methods
This is how I know you're retarded. Stay away from programming please.
>>
>>55754439
>>55754548
>>55754564
>>55754565

Okay so what should I start with? Scheme? Clisp? Racket? Haskell?

I want to go with >>55753710 suggestion but would like to know the best start!
>>
>>55754565

Haskell is for "Purity"

Lisp / Scheme is for "Simple".

Technically if you want to actually be practical you're better with off with Clojure / Scala so you can abuse the large ass java code base.
>>
>>55754622
>Lisp/Scheme
>Simpler than Haskell
>>
>>55754435
Need a pl8 4 dat gr8 b8 m8.
>>
File: large.gif (32KB, 320x240px) Image search: [Google]
large.gif
32KB, 320x240px
>>55754606
All the more reason for me to go back to /Africa/ Java amirite??? Why would my word preference make me have extra chromosomes?
>>55754593


>auto var{" "};
>cin >> var;
>cout<<var;
vs
>Scanner input= new Scanner(System.in);
>String var = input.nextLine();
>System.out.println(var);

yeah, fun times. It's like this shit is purposefully designed for copy-paste
>>
File: 1453726973282.jpg (45KB, 600x600px) Image search: [Google]
1453726973282.jpg
45KB, 600x600px
>>55754548
>>55754564
Thank you. I always hear about how Python or C are the best "begginner" languages, but I started reading Structure and Interpretation of Computer Programs and it's talking about Lisp Scheme. Figured asking you cunts would be a good idea.
>>
>>55754643

Lisp: Minimal Syntax, everything is a list or a primitive. All operations are basically (function (data) ) in various forms.

Haskell: strong static typing, purity is very serious, you have to explicitly deal with data flow, there is plenty of syntax to get started with ( -> , :: , (), [], =>, etc). Monads show up from the very first hello world program.

Literally the only reason to say Lisp or Scheme dialects are harder than haskell is the learning curve on getting used to all the braces.
>>
Class *pointer; or Class* pointer;? I know it's functionally the same, but which is better?
>>
>>55754772
Haskell is simpler, maybe not to write proper Haskell but certainly to use.
You can easily use Haskell imperatively if you really wanted to

You don't need to know Monads to print Hello World
>>
>>55754816
t. Haslel cuck
>>
>>55754796
I prefer the former because it more closely expresses how the language interprets the statement.
>>
>>55754796
if there's more than one use *pointer
otherwise use class*
>>
>>55754321
Nice to see C# goin down baby
>>
>>55754903
To be replaced by Python, Javascript & VB.NET?
Fuck off
>>
>>55754816

You're heavily invested in the haskell mindset.

We're basically arguing if green is a better color than blue :p

Both accomplish similar goals when learned. It's pretty much down to thinking patterns / learning methods which is "better" or "simpler".
>>
>>55754322
Can i have the sauce code for this program?
>>
>>55754985
Different anon here.
>>
>>55754620
>>55754731
Racket. It even has an sicp #lang so you can have perfect compatibility with the stuff they use in the book.
>>
>>55754985
main = print "Hello World!"

(begin (display "Hello, World!") (newline))
>>
>>55754985
LISP/Scheme encourage and allow and forgive sloppy thinking. It's like teaching someone Python as their first language, they get stuck on it because they think other, less forgiving languages are 'too hard'.
>>
File: 1468998107888.jpg (70KB, 634x597px) Image search: [Google]
1468998107888.jpg
70KB, 634x597px
>>55754964
>Python
>& VB.NET?

Lol VB? You mean PHP, and Python already surpassed. Learn how to read charts
>>
>>55755029
>using explicit begin
For what purpose? To keep it in a single statement? Why not just use displayln?
>>
>>55754586
>my program gets statically type checked at runtime :^)
>>
If you think gradual typing or optional typing is remotely comparable to strong, static, mandatory typing then you shouldn't be allowed to program.
>>
>>55755029

Mit-Scheme
(display "Hello World!")

Clisp
(print "Hello World!")


Come on anon.
>>
>muh static types
>get null pointer exception anyway
>can't even have lists of different things
>>
>>55755050
>>55755102
I don't know Scheme
>>
>>55755031
You may be projecting a little here, anon.
>>
>>55755113
>using pajeet-approved languages with null pointers
>>
>>55755102
putStrLn "Hello World!"
>>
>>55755150
I've seen LISP weenies struggle horribly with Haskell. Eventually they give up and declare 'Haskell sucks, it's not practical, it's too hard to get the types right".
>>
do you agree that nodejs is the best thing that ever happened to us?
>>
>>55755200
kys
>>
>>55755198
Haskell does suck though, that's why next to nobody uses it for anything outside of research. If you deny this, you're delusional.
>>
File: help.jpg (9KB, 320x180px) Image search: [Google]
help.jpg
9KB, 320x180px
Would anyone like to learn a language with me? I have no motivation and maybe working with someone would help? I want to learn clojure but I'd be willing to learn almost anything really.. Is this a bad idea?
>>
>>55755224
wow that's a great argument
it sure changed my mind
>>
>>55755228
>if you disagree with me, you are delusional
>>
>>55755252
Exactly. Stay delusional.
>>
>>55755270
i haven't said i disagreed with you

i disagree with you
>>
>>55755252
Not an argument. You're a delusional memeskeller.
>>
>>55755284
t. python >masterrace
>>
>>55755200
It enabled frontend hipster cancer to creep into the backend and desktop application space.
>>
>>55755237
It's a bad idea.
>>
>>55755228
You got me man, Haskell sucks, I admit it. I mean, it has fail as a member of Monad, what other language has that mistake? And seq and unsafePerformIO, oh emm fucking gee, could you even get any worse? Seriously, nearly no languages have those things, except the clusterfuck that is Haskell.
>>
>>55755237
Learn a new language with you? I figure many would rather work on an existing project in a language they are comfortable with.
>>
>>55755247
Glad to be of help, my low test friend.
>>
>>55755295
Python is a meme too, the only real language is C.
>>
File: meh.png (240B, 77x14px) Image search: [Google]
meh.png
240B, 77x14px
>>55755123

scm test.scm results

With this as the file contents

(display "Hello World \n")
(exit)
>>
>>55755237
I'd like to learn Faroese with someone.
>>
>>55755281
I predicted your disagreement. Posts don't have to be synchronous.
>>
>>55755332
s/C/Assembly/
>>
>>55755341
That's actually pretty cool anon
>>
File: 1469310869749.png (458B, 391x391px) Image search: [Google]
1469310869749.png
458B, 391x391px
The course i am enrolling next fall in college (3 years total) has this courses :

> Algebra
> Mathematical Analysis I
> Discrete Math
> Python Programming
> Computer Architecture (intro to assembly, low level theory..)

> Computer Architecture II (assembly, FPGAs, low level stuff..)
> Mathematical Analysis II
> Statistics
> C Programming
> Physics

> Introduction to networks
> Java Programming
> Operative Systems (C language)
> Computation Theory (automata, state machines,...)
> Information theory (entropy, compression,security,...)

> Introducton to Algorithms
> Data Analysis and Transformation
> Multimedia (Actionscript, javascript games)
> Communication Protocols (advanced network stuff)

> Databases (SQL, Java, Oracle, Mysql, Postegres)
> Software Engineering
> Distributed Systems (Java, websockets)

> Computer graphics (C, C++)
> Compilers (C)
> Artificial Inteligence (Python, C#)
> Advanced Algorithms (C, C++)

So my question is:

Can i be called a Software Engineer after i complete this course?


Or, what's the appropriate title in this case?

I know this has some Computer Science courses, so i'm a little confused
>>
File: 1464314955231.jpg (30KB, 326x273px) Image search: [Google]
1464314955231.jpg
30KB, 326x273px
>>55755237
I'm open for it if you want :3
I would probably go for haskell or erlang.
>>
Is there a non-experimental whitespace sensitive LISP? Something like

for n (in-range 1 101)
print
match (gcd n 15)
15 "fizzbuzz"
3 "fizz"
5 "buzz"
_ n
>>
>>55755400
you are a Science Engineer Computer Man
>>
>>55755400
Are you in the UK? What university?

>Can i be called a Software Engineer after i complete this course?
I would go for CS if I were you. SE is a meme degree.
It does have some SE and CS stuff mixed up, I would not call it bad but it certainly could be better.
>>
>>55755400
>Actionscript
>>
>>55755400
there is no consensus on what the title "software engineer" entails
so, yes
>>
>>55755400
You're a hacker.
>>
File: nosebleed.jpg (97KB, 300x300px) Image search: [Google]
nosebleed.jpg
97KB, 300x300px
>>55755401
I could learn either, though I'm a bit of a beginner so you'd have to bear with my stupidness.

On a side note I looked at a bit of haskell and now the right side of my brain now thinks logically.
>>
File: 1454815306892.jpg (70KB, 848x941px) Image search: [Google]
1454815306892.jpg
70KB, 848x941px
>>55755474
What languages do you know anon?
>>
>>55755469
>>55755452
>>55755446
>>55755443
>>55755442
I forgot to say, the official title of this course is "Informatics Engineering "
>>
>>55755368
If I want to learn Assembly and C and have no prior programming experience where should I start?
>>
Want to learn a programming language with the goal of making shitty games that I will never release. Should I learn c++, java, or something else? Best resource for learning said language?
>>
>>55755436
it's called Haskell

import Control.Monad (forM_)
main = forM_ [1..100] $ \n →
print $ case gcd 15 n of
15 → "fizzbuzz"
5 → "fizz"
3 → "buzz"
_ → show n
>>
File: kiki.jpg (3KB, 128x128px) Image search: [Google]
kiki.jpg
3KB, 128x128px
>>55755514
I "know" python. Basically I just want to learn something fully. Or at least to the level where I could call my self a real programmer.

Also I've learned a bit of php and javascript in college, unfortunatley.
>>
>>55755518
Then you're an informatics engineer, my man. Maybe your resume should read:

>Name: Ben Eric Nislover
>Age: 28
>Nationality: Informatics Engineer
>Status: Single, and you know you want me
>>
>>55755567
whoops, buzz & fizz are backwards
>>
>>55755514
English
Norwegian
Esperanto
Spanish
German
Swedish
>>
>>55755557
C++. The C++ Programming Language.
>>
Best build tools for C?
>>
import time

clock = 3

while (clock > .001):
print("Turbo Pancake.")
time.sleep(clock)
clock = clock / 1.5
>>
>>55754086
Is it worth learning/configuring vim or should I just stick with sublime?
>>
>>55755581
I could try teaching you C anon.
>>
>>55755603
why do know all those languages?

do you use them in a daily basis?
>>
Anyone else feel more motivated to fix a bug rather than implement a new feature when programming?
>>
>>55755619
Yes it is because VIM is free software.
>>
>>55755613
that will go on forever, my dude

unless you indent the last line
>>
>>55754989
>Can i have the sauce code for this program?
I will post it when it's done
It's still unfinished and lacks error handling
>>
File: anime.png (21KB, 121x132px) Image search: [Google]
anime.png
21KB, 121x132px
>>55755620
Wait really? Just like that?
>>
>>55755622
I like Germanic languages.

I learnt Spanish at school, and continued it at my university's languages center, and Esperanto because I was interested in the concept.
>>
>>55755674
Oh, and no, I don't use most of them on a daily basis. Only English.
>>
Making another version of the pro/g/ramming challenges and I need some suggestions... Any ideas?
>>
>>55755674
So, you're from USA
>>
>>55755674
How often do you use them tho?
I can't imagine knowing 6 languages unless I was some kind of diplomat.
>>
>>55755641
It looks good anon I would love to use this. Post on GitHub or something. If you finish can you make a thread announcing it?
>>
>>55755690
>Shazam
>medium difficulty
nigga you what
>>
>>55755692
Nah, Britain originally.

>>55755693
I went traveling around Scandinavia several years ago and used my Norwegian and Swedish there, it was good fun. Mostly use German when watching let's plays and twitch.
>>
How does image recognition work? Like Google's tool for searching for similar images.
>>
>>55755690
A lot of this shit is way over a beginner's head(even some of the green ones) but there are also some pretty useful ones in here, I must say. Looking forward to the finished result
>>
>>55755727
what? you think you can make Shazam?
>>
>>55755690
something that compresses and encrypts a directory then uploads it to a file host
>>
File: Stock.jpg (101KB, 1308x712px) Image search: [Google]
Stock.jpg
101KB, 1308x712px
Hey, newbie idiot here. I ran across some decent video tutorials for a python machine-learning library used for stock analysis and it seems like a neat idea for a project. If I were to write a stock trading program, assuming it isn't shit, for a beginner anyway (I'm not new to the math and the algorithms I'd be using are simple enough that they shouldn't cause me too much pain to implement), could I somewhat reliably make a bit of income? Nothing even close to serious, I'm not that stupid. My ambition lies somewhere in the 10$ a month on average range. The reason I care that it makes money isn't because I'm jerk off at the thought of ten extra dollars a month, but it would make the project less rewarding if the outcome was 100% useless.
>>
My girlfriend's father called me a pedophile just because she's 22 and I'm 36.
>>
File: nonNonBiyoriHair.gif (1007KB, 500x563px) Image search: [Google]
nonNonBiyoriHair.gif
1007KB, 500x563px
>>55755620
This is probably just a ruse but if you're serious, like. Email me at [email protected]
>>
>>55755766
Buy him a dictionary for his birthday.
>>
>>55755748
No, I was just thinking that writing a program that records an audio stream and uses machine learning techniques to compare it to millions of songs on the fly would be slightly harder than writing fucking conways game of life.
>>
File: 1461932176436.png (643KB, 678x653px) Image search: [Google]
1461932176436.png
643KB, 678x653px
>>55755766
Get the fuck out you fucking pedo
>>
>>55755754
might be better off with looking into currency trades @ $10/month
>>
So does const do absolutely nothing for optimization and it's just an extra form of type safety / documentation?
>>
>>55755777
the thing is, it ruined our 10-year anniversary.
>>
>>55755766
>>55755766
To be fair, you've lived practically 2 of her lifetimes.
Also, I would think that a 20yo and a 40yo have basically nothing to say to each other because everyone knows that 20yos are boring as hell to talk to.
>>
>>55755786
The compiler may be able to make better optimizations if you use const, but nothing is guaranteed.
>>
>>55755690
Shuffle deck of cards with visuals should also probably be green. Not sure why you chose yellow for it.
>>
>>55755786
it's both

what really helps tho is using *restrict when you're quite sure that your pointers don't point to the same place.
>>
>>55755750
Not sure about the "uploads to a file host" bit, but I'm on board for the encryption/decryption
>>
>>55755811
>BONUS: Assembly
You could say this for any of them

>>55755774
I signed you up to the iTunes newsletter senpai
>>
>>55755766
Does he hate you?
Are you still a virgin?
>>
File: no.jpg (34KB, 710x720px) Image search: [Google]
no.jpg
34KB, 710x720px
>>55755816
>>
>>55755786
Wtf my code tag didn't work. test
>>
>>55755803
The yellow was mostly for the visualization aspect for it
>>
>>55755811
add to the challenges:

make a transcompiler (source-to-source compiler)
>>
>>55755766
yes i browse /r/jokes too
>>
>>55755835
And a ciscompiler
>>
>>55755830
Right, but it's fairly easy to display an array of images with Java.
>>
File: 1446396353816.jpg (36KB, 500x538px) Image search: [Google]
1446396353816.jpg
36KB, 500x538px
>>55755774
I will mail you tomorrow probably anon.
>>
>>55755835
>>55755845

And a combine harvester
>>
There are beginners here that want to learn C but are being suggested shit like Haskell and Python, if you want to start with C, start with C.
>>
>>55755820
it ruined our 10-year anniversary.
>>
File: reflexivos.png (2KB, 176x109px) Image search: [Google]
reflexivos.png
2KB, 176x109px
is this a correct way to represent while/for/recursivity?
>>
>>55755811
>FizzBuzz in Assembly
I made one, but lost the pastebin and the file
That was a good two hours of work
>>
>>55755783
>currency trades
You're right, that is probably the route I should take. Altogether it seems like less of a hassle. Thanks
>>
File: cat.png (66KB, 346x425px) Image search: [Google]
cat.png
66KB, 346x425px
>>55755853
Thanks anon! You made my day!
I'm gonna go brush up on my not being a loser!
>>
File: Untitled.png (40KB, 1000x1000px) Image search: [Google]
Untitled.png
40KB, 1000x1000px
>>55755875
No
>>
>>55755875
What kind of diagram is that?

v--task
| ^
| |true
v | false
cond =^------------>
>>
File: Untitled.png (6KB, 327x237px) Image search: [Google]
Untitled.png
6KB, 327x237px
>>55755829
test
>>
>>55755919
while starts at cond
do while starts at task
>>
File: Screenshot_27.jpg (74KB, 806x188px) Image search: [Google]
Screenshot_27.jpg
74KB, 806x188px
I just started reading Computer Systems-A Programmers Perspective. And it recommends using Linux-based OS for the material. I use Ubuntu myself (I know, not very hardcore), but am curious as to why they would say this.
I don't know why it'd be advantageous to use one OS over another for this material. So far from what I've read, they only move through directories and compile C programs from terminal.
>>
>>55755924
(println "like this)
>>
>>55755935
Jesus anon git gud already
>>
>>55755935
Windows's CLI environment is absolute dogshit. Many programmers choose to work on Linux just because of the shell.
>>
>>55755935
Windows is not POSIX compliant. Almost every other operating system is.
>>
File: Untitled.png (9KB, 319x228px) Image search: [Google]
Untitled.png
9KB, 319x228px
>>55755949
Maybe it actually needs whitespace inside the tags to work test.
>>
>>55756000
c:
>>
>>55755919
i dont know it was in this page.
http://www.cpxall.com/2012/01/modelo-entidad-relacion.html

i never saw anything like that before.
>>
>>55755690

Why is a vm purple?

Hell.. Why would a Dragon quest / basic rpg be considered green when it is arguably more difficult than Chip -8 Emulator, Tetris, and Pacman.
>>
>>55756019
test
>>
>>55755959
I'll get there.

>>55755965
Is being able to use shell just a preference of workflow?

>>55755969
Is being POSIX compliant just standards set for industry? Why would being POSIX compliant be good for development?
>>
>>55756000
Maybe it can't be inline and has to be on its own line.
test
>>
>>55756077
No anon git gud now, it's the only way
>>
>>55756079
 test same problem here[ /code]
>>
>>55756079
please stop

>>
>>55756102
>>55756079
 Only use code one time, the / is not needed ?
>>
>>55756077
>Is being able to use shell just a preference of workflow?
Workflow. I can't work on Windows anymore because it restricts me to only using GUI programs. Ask anyone who uses git which is better, its CLI or GUI version.
>>
 String Str = "Donal Trump"
>>
>>55756043
Purple is "Harder than the red ones" and represent something like a project you would do across a month with constant work., while still being doable

For the RPG/Dragon Quest, There was a small miscommunication and I meant to say "RPG Engine" which is not necessarily *that* difficult, in my humble opinion
>>
File: Untitled.png (6KB, 312x220px) Image search: [Google]
Untitled.png
6KB, 312x220px
code
code
 code
code code
code
code
code
>>
File: Untitled.png (5KB, 336x220px) Image search: [Google]
Untitled.png
5KB, 336x220px
code
code code code
code
>>
>>55756148

If you're talking text adventure style sure.

A actual rpg engine is a pretty complex project. Stat systems, equipment / inventory management, menu drawing / interaction, a file format for saving / loading games, some sort of flag system for events, tiling graphics, enemy / npc scripting, and tools for editing them all.

As for the vm it depends on what you define as a the minimal requirements. A chip8 emulator itself is just implementing a old vm to specs.
>>
File: aaaநெ.jpg (25KB, 377x230px) Image search: [Google]
aaaநெ.jpg
25KB, 377x230px
>>55756144
>String Str
>>
>>55755811
Dobber gegger

Also working on a discord bot. Is there a /g/ programming discord?
>>
>>55756278
Alright... I'm convinced. Changed the RPG from easy to medium
>>
Alright lad just configured VIM and used it to write fizzbuzz in python, liking it so far
>>
>>55756328
Why are you so obsessed with neural networks?
>>
>>55756315
Not to my knowledge, no... And I have no idea what Dobber Gegger is. (Is it a "double getter", perhaps?)
>>
>>55755436
>>55755567

F# also works

for i = 0 to 100
print
match i % 3, i % 5 with
| 0, 0 -> "FizzBuzz"
| _, 0 -> "Buzz"
| 0, _ -> "Fizz"
| _, _ -> string i
>>
>>55755699
I will post itt
>>
File: jrpg-architecture.png (22KB, 310x461px) Image search: [Google]
jrpg-architecture.png
22KB, 310x461px
>>55756328

Yeah that's probably a better fit for it.

This is a nice image to breakdown a basic dq / ff style rpg :P
>>
>>55756433
Thanks! This is actually really useful!
>>
>>55756433
:P
>>
Just started scala but how do you deal with

<console>:12: error: not found: type Oof
<console>:12: error: not found: type Foo

class Foo {
def bar (j: Oof) = ()
}

class Oof {
def rab (n: Foo) = ()
}
>>
>>55756459

Yeah I did a lot of work on a 2d rpg back in 2010 or so.
>>
How can I have serveral things on one line in python 3.x here's the code in bash how would I do it in python
read -p "Enter your values" val1 val2 val3
print $val1
print $val2
print $val3


so how would I do that in python?
>>
>>55756619
s = raw_input("Please enter a list of numbers separated by commas:")
print(len([i for i in s.strip().split(',') if int(i) >= 0]))
>>
>>55756633
>X if P else Y
God damn, python ternary statements are beyond retarded.
How can anyone defend that shit?
>>
>>55755690
>Fizzbuzz in Assembler
It's 4 AM.

I'll go more autistic.

I have to write it all in ed.

I was initially thinking emacs but that wasn't autistic enough.
>>
>>55756649
because it's natural english.
compare to
P?x:y;
>>
>>55756649
Disgusting

if :: (forall a. a -> a -> a) -> a -> a -> a
>>
>>55756669
>because it's natural english.
How is that an advantage? You're writing a program, not a fucking book.
It also doesn't make sense for non-english speakers.
>compare to P?x:y;
Infinitely better. I can see that it's a conditional right away.
>>
>>55756692
>How is that an advantage?
what you just said is that you don't care about code readability
not much point in me responding to that
>>
>>55756749
>you don't care about code readability
I care immensely. The python way is just fucking retarded
if_true conditional if_false

is just retarded in so many ways.
It doesn't start with a conditional, so at a glance, if_true looks like normal code that will execute every time.
The conditional is between code, obscuring that it's there.
The ways you visually parse it is stupid.
second if first else third

compared to the much more sane, left-ro-right
first ? second : third
>>
I'm trying to write a simple program that takes a sentence as input and capitalizes the first letter of every word. This is what I came up with but it's not working and I can't figure out why. Any help?

void main()
{
int c;
char array[32];
int pos = 0;
while((c=getchar()) != '\n'){
if(c != ' '){
array[pos] = c;
++pos;
}
else if((array[0]) < 65 && (array[0]) > 90 ){
array[0] -= 32;
for(pos; pos>0; --pos)
printf("%c",array[pos]);
pos = 0;
}
else{
for(pos; pos>0; --pos)
printf("%c",array[pos]);
pos = 0;

}
}

}
>>
>>55755610
make
>>
GOD FUCKING DAMMIT I GOT AN 8 THAT SHOULDN'T BE IN MY PROGRAM SHOWING UP IN AN ARRAY POSITION THAT I NEED IT NOT TO SHOW UP IN AND I CAN'T FIGURE OUT WHERE IT'S COMING FROM REEEEEEEEEEEEEEEEEE
>>
>>55756886
void meme(char *str, char *new)
{
int i = 0;

// increment first letter in the sentence
new[i] = toupper(str[0]);
i++;

// read sentence til the end
while (str[i]) {
if (isspace(str[i])) {
new[i] = str[i];
new[i + 1] = toupper(str[i + 1]);
i += 2;
} else {
new[i] = str[i];
i++;
}
}
}
>>
File: Screenshot_2016-07-25_20-30-37.png (12KB, 224x40px) Image search: [Google]
Screenshot_2016-07-25_20-30-37.png
12KB, 224x40px
>>55756978
Every fucking time. Every single fucking time when i run this program this little faggot just sits there and puts backspaces in my terminal. What should i do about him? Ideas?
>>
>>55757072
post the fucking code
>>
>>55757091
Nah, I'm just venting and meming here, I'll get it eventually.

Goddamn, it's gonna feel so good when I finally figure out what the problem is
>>
>>55756886
#include <stdio.h>

int main() {
char c, prev = ' ';
while ((c = getchar()) != '\n') {
if (prev == ' ' && c >= 'a' && c <= 'z')
putc(c - 'a' + 'A', stdout);
else
putc(c, stdout);
prev = c;
}
}
>>
am I doing this database thing correctly?
    sqlite3 *db;
sqlite3_stmt *stmt;
sqlite3_open("data.db", &db);
sqlite3_prepare_v2(db, "SELECT field FROM sample;", -1, &stmt, NULL);
while (1)
{
sqlite3_step(stmt);
int len = sqlite3_column_bytes(stmt, 0);
if (!len)
break;
char *data = (char *) malloc(sizeof(char) * len + 1);
char *col = (char *) sqlite3_column_text(stmt, 0);
strcpy(data, col);
printf("%s\n", data);
free(data);
}
sqlite3_finalize(stmt);
sqlite3_close(db);
>>
How do I, in JavaScript, search through an array get all of an object's values (e.g. grade_scores) based on a unique name (e.g. school_name)?
>>
>>55757139
>
c >= 'a' && c <= 'z'

Unportable

>>55756886
Unportable and ho9mosexual
>>
>>55754262
PROLOG ABOVE ALL
>>
>>55757183
>Unportable
kekerino
>>
>>55757212
Wrong
>>
File: 1441640541612.png (1MB, 1280x720px) Image search: [Google]
1441640541612.png
1MB, 1280x720px
>>55757141
>>
>>55757139
>>55756886
>>55757183
#include <stdbool.h>
#include <stdio.h>
#include <ctype.h>

int main()
{
int c;
bool space = true;
while ((c = getchar()) != EOF && c != '\n') {
putchar(space ? toupper(c) : c);
space = isspace(c);
}
putchar('\n');
}
>>
>>55757223
listen buddy

you can't call something is unportable and not post the *portable* version

therefore, that code is portable.
>>
>>55757269
Damn, that's a pretty retarded leap in logic.
Anyway, the version I posted in >>55757262 is portable.
>>
>>55757262
#include <stdio.h>
#include <ctype.h>

int main()
{
char c;
int space=1;
while ((c = getchar()) != EOF && c != '\n') {
putchar(space ? toupper(c) : c);
space = isspace(c);
}
puts("");
}
>>
>>55757269
>you can't call something is unportable
I clearly can.

>and not post the *portable* version
One person did before me actually.

>therefore, that code is portable.
Only a tard could claim that.
Read the standard.
>>
>>55757280
and why isn't portable, mind telling ?
>>
Can someone post the original programming challenges image?
>>
Someone give me something for a beginner to do in python
>>
>>55757297
Your changes are terrible and actually cause problems.
>>
File: 1468618371689.png (1MB, 3840x2160px) Image search: [Google]
1468618371689.png
1MB, 3840x2160px
>>55757313
>>
>>55757329
Thanks anon
>>
>>55757297
No, that's wrong you fucking idiot.

>int space=1;
There was no reason to remove stdbool.h. My code already wasn't C89 compatible (always write to the latest C standard), so stdbool is guaranteed to be there.

>char c;
Wrong. getchar returns an int, and it can be outside the range of unsigned char, when it returns EOF.

>puts("");
There is no reason to use this over putchar('\n');
>>
>>55757323
No they aren't. stop being an autistic shit

fucking retard thinks he knows everything
>>
What would a database schema look for an imageboard like 4chan?

I imagine every thread has it's own table for posts and every active thread is listed on a separate table which can be inner joined with the same post ID?
>>
>>55757312
It assumes that ASCII is the character encoding used.
Also it doesn't handle EOF correctly.
>>
>>55757346
Ah, so you were trolling. Got it.
>>
>>55757344
>No, that's wrong you fucking idiot.
No it's not
>There was no reason to remove stdbool.h. My code already wasn't C89 compatible (always write to the latest C standard), so stdbool is guaranteed to be there.
>stdbool.h
>importing a library that does
>#define true 1
>#define false 0
kek

>Wrong. getchar returns an int, and it can be outside the range of unsigned char, when it returns EOF.
you can use char you faggot

>There is no reason to use this over putchar('\n');
There is no reason to use putchar('\n') over puts("");
>>
>>55757357
>It assumes that ASCII is the character encoding used.
When would you use anything else
>>
>>55757359
>Your changes are terrible and actually cause problems.

off yourself
>>
>>55757376
>>stdbool.h
>>importing a library that does
>>#define true 1
>>#define false 0
_Bool has different semantics than an ordinary integer type. Why not important in this particular example, it's something you should know about.
Also the triviality of the header's implementation is not important.

>you can use char you faggot
Again, it doesn't handle EOF properly, you fuckface.

>There is no reason to use putchar('\n') over puts("");
It would be slightly more efficient.
>>
>>55757376
>>importing a library that does
It's not a library, it's a header

>you can use char you faggot
>ignoring the "and it can be outside the range of unsigned char, when it returns EOF."
>>
>>55757387
https://en.wikipedia.org/wiki/EBCDIC
>>
>>55757388
It's a fact. Enjoy being wrong.
>>
>>55757401
>_Bool has different semantics than an ordinary integer type. Why not important in this particular example, it's something you should know about.
>Also the triviality of the header's implementation is not important.
in C 1 == true, so shut the fuck up

>Again, it doesn't handle EOF properly, you fuckface.
you're right

>It would be slightly more efficient.
show me the decompiled assembly code and benchmarks proving that
>>
>>55757426
>It's a fact. Enjoy being wrong
>doesn't prove why

Not an argument
>>
>>55757438
>in C 1 == true, so shut the fuck up
>>not important in this particular example
bool a = 0.5;
int b = 0.5;

>show me the decompiled assembly code and benchmarks proving that
It's a function that doesn't have to deal with strings.
>>
So here's how I've been learning python, picking a project then just googling and modifying/putting code together - Is this a good idea or should I get a beginner book?
>>
>>55757463
Nej, å lære Python er en forferdelig idé, du bor lære Haskell.
>>
>>55757463
solve this problems

http://codingbat.com/python

they are really easy
>>
>>55757449
>doesn't prove why
I did prove it, duh.
>>
File: 1.png (210KB, 519x487px) Image search: [Google]
1.png
210KB, 519x487px
>>55755051
>interpreted languages don't generate vm bytecode
>>
>>55757420
Why would you use that
>>
original poster here, finally made the code work but it just turned out into a disgusting, hacky, redundant mess lmao, posting so you can all laugh at my ineptitude.

void main()
{
int c;
int i;
char array[32];
int pos = 0;
while((c=getchar()) != '\n'){
if(c != ' '){
array[pos] = c;
++pos;
}
else if((array[0]) >= 'A' && (array[0]) <= 'Z' ){
for(i=0; i<pos; i++)
printf("%c",array[i]);
pos = 0;
putchar(' ');
}
else{
array[0] -= 32;
for(i=0; i<pos; i++)
printf("%c",array[i]);
pos = 0;
putchar(' ');
}
}

if((array[0]) >= 'A' && (array[0]) <= 'Z' ){
for(i=0; i<pos; i++)
printf("%c",array[i]);
pos = 0;
}
else{
array[0] -= 32;
for(i=0; i<pos; i++)
printf("%c",array[i]);
pos = 0;
}

}
>>
File: Screenshot_2016-07-25_21-15-00.png (741KB, 1600x900px) Image search: [Google]
Screenshot_2016-07-25_21-15-00.png
741KB, 1600x900px
Finally got that whole 8 problem sorted out (pointers are hard)

Here's my VM running Hello World. I'm pushing the string "Hello World!\n" onto the stack backwards and then popping the string off into "memory" before printing it (ensures the string is in order when it's layed out in memory). I'd use a mov function, but it's not implemented yet.
>>
>>55756486
I don't think it has circular inheritance.
>>
>>55757574
>>55755051
>>55754586
>>55754559
>>55754228
Tards
"interpreted" is a property of the implementation
>>
>>55757630
>(pointers are hard)
Are you seriously writing it in C/C++ without having mastered pointers already or are you implementing pointers in your language
>>
File: Capture.png (63KB, 1367x664px) Image search: [Google]
Capture.png
63KB, 1367x664px
playing around with controlling arduino stuff through raspberry pi. nothing substantive but that's /dpt/.
>>
>>55757685
They were working fine in my VM code for awhile, and then I made a change to the code and they started causing weird behavior. Got it all sorted out though.
>>
>>55755400
You gotta make some projects of your own for it to count.
>>
>>55757728
Neat
>>
Just starting off the "Handmade Quake" series. Kinda wish there was a non-video version and a version that used X11 so I could Linux it
>>
What's the most complex project you've programmed?
>>
>>55757983
Started writing an OpenGL wrapper for 2D games back in highschool, got somewhat far with it but never finished.
>>
File: common pepe.jpg (36KB, 709x765px) Image search: [Google]
common pepe.jpg
36KB, 709x765px
>when the language isn't case sensitive
>and the documentation isn't consistent
>>
>>55758073
>when the language isn't case sensitive
Which languages do this
>>
>>55757725
>nothing substantive but that's /dpt/.

Yep.
>>
>>55756649
>>55756669
No it's not

You'd say the condition first
if p then x else y
>>
>>55758073
R A R E
A
R
E
>>
>>55757983

Server for a game that had to handle a really large amount of users and controlled npcs server side (Ai / Movement).
>>
File: output.webm (2MB, 480x640px) Image search: [Google]
output.webm
2MB, 480x640px
>>55757725
cool brah
i made something a while back
also not substantive
>>
>>55758114
Can you talk about that? Sounds interesting.
Language? How did you properly manage all that data?
>>
>>55757725
I want to get into arduino, but I don't know anything circuits. I guess it's time to hit the books.
>>
>>55758155

C++ it used sql for user records and to store npc info. There was a lot of dirty hacking to keep processing requirements down. Any more than that I'm sorry to say I can't disclose due to contract.
>>
File: idl.png (22KB, 934x711px) Image search: [Google]
idl.png
22KB, 934x711px
>>55758081
>>
>>55758192

Some other general stuff I believe is fine to give away.. We allocated most of the server's memory at startup in huge pages and managed it with a custom allocator. It used a custom network driver. Multi-threading in a way that could handle things was a beastly heart breaking bitch.
>>
>tfw too dumb for assembly
>>
class PajeetsFirstProgram
{
public static void main(String[] args)
{
System.out.println("Hello Telephone");
}
}
>>
>>55758328
why would you ever need to use assembly?
>>
>>55758338
cause I want to join the software crusade and make TempleOS 2.0
>>
>>55758364
thanks for the giggle m8
>>
>>55758338

Reverse engineering is still a big common task.

It's kinda hard to do without decent knowledge of x86 and x64 assembly.
>>
Could somebody point me to a decent javascript brainfuck interpreter? I need it for a machine learning application and I really don't feel like writing my own, given how much other stuff I have to do.
>>
I'm currently mastering VisualBasic
>>
>>55759083
how exactly is that going, champ?
you using .NET or classic 6.0?
>>
>>55755619
Santeria is better ;)
>>
>>55759083
Why not CuteSharp?
>>
File: 1395691541096.jpg (12KB, 199x193px) Image search: [Google]
1395691541096.jpg
12KB, 199x193px
>>55759100
.Net
I'm 32. I've had a computer since the dawn of computing. My life has been spent on a computer but I never took any programming classes. But now that I'm 32 I want a real job so I started at the beginning. I wish I had done this when I was younger because I feel much of brain is mush. I see these young kids in class and I feel like a moron. Oh well, I'm not quitting yet.

I started with Alice, which was so easy that I could have learned everything we needed in one day. But, now that I'm in VB I feel like I'm treading water. I get it, but it's not coming easily. Like I said, I think my brain is mush.
>>
>>55759188
>I want a real job
>VB
kek
>>
>>55759179
c# in fall. I'm at the beginning.
>>
>>55759197
intro to programming. first class.
>>
>>55759214
Use a language made for that then, like Scheme.
>>
>>55759199
Naice, good luck buddy.
I'm learning C#, and so far seems like a good language. IMO sometimes feels like it has too much features, but overall I like it.
>>
>>55759223
VB is what they teach in that class. It's just getting me familiar with things.
>>
>>55754228
Because the developers were too stupid to write a compiler.
>>
>>55759255
isn't a compiler easier to write than an interpreter?
>>
>>55759291
depends what language you're using
>>
>>55759291
no
>>
>>55759348
assume C

>>55759412
elaborate
>>
>>55759418
Writing an interpreter is easier.
>>
>>55759430
I don't think you understand what the word elaborate means
>>
>>55759441
Maybe this is indeed the case, maybe I don't even know what the word word means, who knows.
>>
>>55759418
in C it might be easier to write a compiler, especially a transcompiler, but in a higher level language like Haskell it's easier to write an interpreter
>>
is this the /beginnerhaskell/ thread

>tfw don't know when to use let vs where
>tfw don't know when to use if vs case vs pattern matching

I come from lisp so I prefer using expressions for now
>>
>>55759871
also
>tfw i don't know if i should be handling exceptions like "first of an empty list", and even what to do if I do want to handle them (Maybe monad? throw exception?)
>>
>arrays can be idexed by using () or []
FUCK THIS LANGUAGE.
>>
>>55759998
what lang?
>>
>>55760011
Scala
>>
>>55759871
whatever you like

>>55759884
depends what you're doing, generally you want stuff to work with all inputs

>>55760030
I think you can do it in Haskell too
(well (), not [a])
>>
>>55760011
I'm >>55759998
It's IDL
This language is so fucked.
>>
Haskell is such a big piece of shit
>>
rolling for project
>>
>>55760045
-- haskell
v = array ((), ()) [((), 0)]
-- the first parameter is the bounds of the vector
-- the second is a list of key (index) value pairs
-- () is defined as a bounded enum with 1 value
>>
>>55760091
this is from the array package btw, not prelude
>>
NEW THREAD!

>>55760118
>>
>>55760091
I don't know what you're trying to tell me here, but in IDL
v = [1,2,3,4,5]
v(0) == v[0]
1
V(0) == v[0]
1
>>
>>55760121
Oh, I meant you could use the unit type () to index arrays in >>55760107
>>
>>55760121
actually this is wrong.
IDL doesn't use == it uses eq or EQ or eQ or Eq
>>
>>55757924
You could just replace the win32 calls to create the window with x11 calls or use SDL.
>>
File: image.png (78KB, 1327x668px) Image search: [Google]
image.png
78KB, 1327x668px
>>55755690
I did something like the stock simulator thing in Matlab.
>>
Why didn't anyone tell me how comfy vim is?
>>
How do I add like -h and stuff to python?
Thread posts: 315
Thread images: 48


[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.