[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: 314
Thread images: 18

File: 2000px-Haskell-Logo.svg.png (36KB, 2000x1412px) Image search: [Google]
2000px-Haskell-Logo.svg.png
36KB, 2000x1412px
we dindu nuffin edition

What are you working on /g/?
>>
>>56118257
First for D
>>
First for C.
>>
Is programming not allowed on /g/ anymore?
What?
>>
>>56118279
The past two threads have been /pol/ related stuff and threads go off topic because of it. Maybe this one will last.
>>
>try to make string compare and fail
>it's actually working as intended, 1 is equal to 2.
>>
Rate my hex converter!
char hex_value(char c)
{
c -= (c >= 'a' && c <= 'f') ? ' ' : 0;
if (c >= '0' && c <= '9')
return c - '0';
else if (c >= 'A' && c <= 'F')
return c - '7';
else
return 0;
}

unsigned parse_hex(const char *str)
{
unsigned result = 0;
unsigned i;
for (i = 0; i < strlen(str); i++)
result = (result << 4) | hex_value(str[i]);
return result;
}
>>
>>56118279
Fags here would rather have anime than the redpill. Fuck anime, I hate that degenerate trash so much.
>>
>>56118316
You're on an anime website, faggot.
Also, most of /pol/ loves anime and traps, despite all their stormfront memes.
>>
>>56118326
Stop projecting your degeneracy.
>>
>>56118310
Is strlen called every iteration here? I don't know if the compiler would detect that str isn't being changed in the loop and optimize it out.
>>
>>56118351
>>56118331
your off topic spam has resulted in the last 2 /dpts/ being deleted
fuck off

>>56118354
any sane compiler would optimize it away
i looked with gdb once, it does optimize it under gcc
>>
>>56118363
Accept the redpill or accept the rope. If you're a kike or fag you get the oven. This is an alt right website.
>>
>>56118363
Ah, I didn't know that, neat.
>>
>>56118363
>any sane compiler would optimize it away

it can only do that if it's sure that *str isn't being changed in any way within the loop body
>>
>>56118400
is that why all the trump supporters on twitter have anime avatars and post pictures of awoo wearing that maga hat?
>>
>>56118478
>all trump supports
Nice to know you meticulously combed twitter and found all trump supporters.
>>
>>56118257

Working on firmware for my nixie clock in C++.
>>
>>56118478
That's a meme anime and the anime shown on /pol/ is the limited selection of anime that isn't pedo shit, fags, or traps
>>
File: TrumpShrine.gif (2MB, 380x214px) Image search: [Google]
TrumpShrine.gif
2MB, 380x214px
>>56118478

Is this better?
>>
>>56118354
I checked the assembly in clang with and without optimizing and both retain the strlen in the loop.
>>
>>56118531
top kek
Save the strlen in a variable and then use that as the condition then
>>
>>56118504
I feel like you're just throwing a fit because you figure this is the fastest way to fit in on 4chamm

You're a faggot far-right social justice warrior.
Now post computer code or fuck off.
>>
>>56118531
clang is trash
gcc doesn't do that
>>
Learning Java.
>>
>>56118568
What's the point of this post?
>>
>>56118547
I'm trying to stop the jews from killing the white race and you're busy jacking off to anime like a degenerate. I'd kick your fag ass if I knew you.

And yes, this is an alt right website. It's no longer a degenerate lolicon anime website but a redpill website.
>>
>>56118531
>>56118562
On second thought clang and gcc both optimize it out, godbolt was just being retarded.
>>
This is all my fault
I should have left out "we dindu nuffin edition"
>>
>>56118588
What the fuck is your problem?
Are you paying for 4chan's servers memory or what?
>>
>>56118609
you wanted this to happen
>>
>>56118619
Legitimate question, dude.
>>
>>56118562
This
>>
>>56118603
You're the only one making threats and claiming that all anime fans need to be gassed and hung from trees because you forget this is an anime website.
>>
Can we delete this thread and start over?
>>
>>56118652
This is not an anime website
>>
>>56118652
>>56118603
You are both colossal stains on your family lineage.


Like VB.NET
>>
I'm just contemplating what to do next for my image viewer. In the meantime I'm fixing bugs and testing features.
>>
File: 1471037958015.jpg (95KB, 609x410px) Image search: [Google]
1471037958015.jpg
95KB, 609x410px
>>56118668
I like toast.
Toast is nice.
>>
I find it ironic that declarative languages are the best at sequencing operations. Imperative languages are all about sequencing operations and they can't seem to graduate beyond "do this and then immediately do this".
>>
File: Explain.jpg (39KB, 649x536px) Image search: [Google]
Explain.jpg
39KB, 649x536px
>>56118680
>This is not an anime website
>>
>>56118680
>anime on the banners
>anime on the ads
>anime on the 404 messages
>15 boards dedicated to anime and anime pornography drawings
but go ahead and keep saying that, you redditor
>>
>>56118697
>Perhaps cpus should be designed to do illogical things that nobody would understand nor be able to code for...

Yes. One agrees...
>>
>>56118697
Modulo language features like exceptions or async/await.
>>
Can we all just discuss how Python is such an amazing language and that we need to get rid of PERL?

It's fast, flexible, easy to read, and is the first thing you learn

literally the best language in the world
>>
Jesus, we're at like 3 threads deleted and I wouldn't be surprised if this one were nuked, either.
>>
>>56118733
If I wanted my programming language to map directly to machine code, I'd use assembly.
>>
>>56118705
It used to be but it's not anymore. Every board has educated about the nose, that's what this site has become into, redpilling. Sites change over time anon. The sooner you get over your autism the better.
>>
>>56118749
>It's fast
lol
>>
>>56118749
> Anal is better than licking wall sockets...

You have a point there... someplace!
>>
File: lowqual.jpg (1KB, 100x100px) Image search: [Google]
lowqual.jpg
1KB, 100x100px
>>56118749
>>
>>56118730
Those are containment boards and weebs have to shove their autism in everyone's faces
>>
>>56118783
Is /po/ a containment board for people interested in origami?
>>
File: pomfu.jpg (49KB, 300x300px) Image search: [Google]
pomfu.jpg
49KB, 300x300px
>>56118783
>>56118758
what drives a person to kick and scream about anime on an anime imageboard?
>>
>>56118771
Why else would the NSA use it if it wasn't the most effective language
>>
>>56118809
Almost nobody posts on /po/
>>
>>56118825
Answer the question.
>>
>>56118823
...I just realize that the NSA paid Google to make their hacking tools.
>>
>>56118833
/po/ is the most racist and sexist board on this website

Now what does /po/ have to do with cudder?
>>
>>56118833
No, it's not. Terrible example because it's a dead board. You have 15+ boards for your degeneracy. You'll grow up one of these days.
>>
>>56118257
StrongAI that works... not some weak-ass pussy shit using restricted fucking Boltzmans or retarded Perceptron-based ass emissions.

Be a man... sign up for the Front Line today!
>>
>>56118822
It's not an anime imageboard
>>
Lord have mercy on our souls.
>>
How do you deal with complexity once a program grows beyond 500 lines? I'm writing a web server in haskell and I've been stumped the last couple days trying to refactor this mess. I thought haskell would make my life easier?
>>
>>56118891
prove it
>>
>>56118891
Where's fucking Spiderman when you actually need that fucker.....
>>
>>56118912
The lolz come thick and fast here sometimes.....
>>
What programming projects should I do to build a good github?

Also, is it just me or are stormcucks getting louder here after the nsa hack?
>>
>>56118912
compartmentalization
write everything as if you're writing general purpose library code

this is especially important in C, because there's no such thing as namespaces.
>>
>>56118912
I don't know about Haskell but in general you should try to break your shit into as many functions as possible.

That way if you change a function .e.g. making it better while still retaining the same interfaces the program will still work like it did before.
>>
>>56118913
>>56118917
/pol/ has become the face of this website over the past few years and is shifting the tide of the election and has created several memes the internet talks more about than your chinese cartoons
>>
>>56118935
Do something with networking/sockets. Doesn't have to be too complicated.

Make a socket that echos anything you send it.
>>
>>56118941
>modularity... oop... normal shit you should be using anyhow...

We never done thought of that.
That's wondrous advice.
I shall take it on board immediately.
>>
>>56118963
/pol/ is just old /b/ with less gore and snacks
>>
>>56118619
kek'd

+1
>>
So I have a string input, and I want to remove all non alpha characters, then sort and group the characters together, with an empty list for ones which don't exist.

What I have so far is this
alpha = group $ sort $ filter isAlpha (map toLower input)


Given an input, say "I really really like this picture. Save it friend, it's all yours!" it outputs
["aaaa","c","d","eeeeee","f","h","iiiiiii","k","lllllll","n","o","p","rrrrr","ssss","tttt","uu","v","yyy"]


I would like it to do this, but between 'a' and 'c', have an empty "" for 'b'.
>>
How do I into C without IDE on Linux
What should I look into
>>
Do you like object-oriented programming or just objects? Think about it for a second.
>>
>>56119104
nano
gcc
valgrind

that's all you need really
>>
>>56118685
bazinga
>>
>>56119104
Whatever editor you like, and gcc.
>>56119107
Both, sometimes using inheritance and interfaces are useful.
>>
>>56119109
Nano is for plebs who basically use it because it's not notepad. Use either VIM or Emacs.
>>
>>56119104
>>56119109
look into vim or emacs as a replacement for nano as well, but nano is good enough of course
>>
>>56119126
Interfaces are just types.

Inheritance is sugar for a specific case of composition + interface implementation.
>>
>>56119149
Yes, thanks for the explanation tho.
>>
>>56119174
So object-oriented programming is using types and a certain kind of syntax sugar?
>>
>>56119109
i forgot to add make
make is a godsend

v>>56119129
>>56119127
vim and emacs are for people who like the idea of programming more than they actually enjoy programming.
your typical vim/emacs zealot will spend weeks of their time ricing their editor until it resembles and performs like a IDE.
But they will be quick to tell you it's not an IDE, because they've built up this idea in their head that only mindless codemonkeys and pajeets use IDEs.
>>
>>56119199
It isn't, but a lot of things that are that call themselves OOP.
>>
>>56119200
Emacs was designed to be an IDE, that's what separates it from VIM.
>>
>>56119217
>emacs was designed to be an OS

fixed
>>
>>56119200
>your typical vim/emacs zealot will spend weeks of their time ricing their editor until it resembles and performs like a IDE
[citation needed]
>>
File: vim.png (137KB, 649x597px) Image search: [Google]
vim.png
137KB, 649x597px
>>56119239
this was posted to /g/ a few hours ago

this is what they referred to an ideal vim environment
>>
>>56119227
Right, thank you. And that's why I love Emacs. It can replace almost every OS feature except the browser, the upcoming webkit browser will fix that.
>>
>using an OS nee text editor while running an IDE nee OS
>>
>>56119200
I don't know about the typical vim or emacs user, but probably the vocal vim or emacs user, yeah. I use vim all the time and it's vanilla.
>>
>>56119256
That doesn't prove what you said at all.
>>
System.out.println("8========D");
>>
>>56119256
>one person does it
>the majority do it
>>
>>56119256
looks like shit tho.
>>
>>56119199
OOP is programming in terms of objects and messages

Even the majority of OOP fags don't do proper OOP any more
>>
>>56119306
Right? OOP to most people now is "Classes, inheritance, polymorphism"
>>
>>56119306
That's my point in asking >>56119107.

Objects are a useful tool and model, of course, but following OOP and using them as your golden hammer is nonsensical and I don't understand how it has become the industry standard.
>>
>>56119129
>>56119126
>>56119109
I've got a text editor already, I'm having trouble with the compiling part
Using gcc manually is okay while I'm just making single-file things, but what about when I'm doing something with several headers and files and libs and shit

>>56119200
So I should learn make then?
Any recommended tutorials to get a quick start? The documentation looks huge
>>
>>56119331
I should have said
>following "OOP"
>>
>>56119347
>but what about when I'm doing something with several headers and files and libs and shit
make
>>
>>56119306
We do. My team spends most of the time engineering the best possible architecture and every detail to make the best out of OOP. Most of commercial projects are made this way.
>>
The servers at work don't have vim. The have vi. It's a pain in the ass not being to move the cursor around in edit mode.
>>
>>56119319
>the notion that polymorphism only exists as single dynamic dispatch through method overriding in subclasses
REEE
>>
>>56119370
>best possible architecture
>OOP

>>56119379
>>>/r9k/
>>
>>56119347
Makefile

even without make its okay, i mean `gcc main.c thing.c thing2.c thing3.c thing6.c -lm -llibrary -lotherlib' isn't half bad, although using a Makefile is better
>>
>>56119391
What i mean is that we use OOP to make our architecture better, not base the whole architecture on OOP.
>>
>>56119427
That's not OOP, then.
>>
>>56119427
I very much doubt it's actually OOP and not just structure
Inheritance heirarchies aren't even OOP
>>
>>56119347
make is incredibly simple
it only gets complex when your needs are complex
here's a simple makefile that should be adequate for all your projects until they get so complex that they take minutes to recompile and require selective recompliation.

CC=gcc
CFLAGS=-O2 -ansi -g -Wall
LDFLAGS=-lm
INCLUDES=include
SOURCE=src
INPUT=$(wildcard $(SOURCE)/*.c)
OUTPUT=program_name

all:
$(CC) $(CFLAGS) -o $(OUTPUT) -I $(INCLUDES) $(INPUT) $(LDFLAGS)

clean:
rm -rf $(OUTPUT)
>>
>>56119437
It is, though ;)
You just don't get paid enough to believe it.
>>
How would designing a program to be made in an OOP language differ from designing a program to be made in an FP language?

For example, how would a programmer planning to build a GUI text editor in C++ vary from planning to in OCaml?
>>
>>56119456
It cannot be OOP if you're not applying it everywhere.
>>
>>56119469
You serious?
>>
>>56118958
The thing with haskell is it's a pure language. You can't just write a "database" library without every part interacting with "IO". But then you want error handling so you wrap the results using "Either". But you might need other aspects of the main frameworks data so you return a monad. But to incorporate error handling with a monad you need the "ExceptT" monad transformer. I've done all that, which is the easy part. The hard part is I've been doing this in different parts of the code in similarish ways and have this vague feeling I'm repeating myself badly, and that there's some typeclass or data structure I should be defining but can't quite put my finger on it.
>>
>>56119469
C++ isn't an OOP language
>>
>>56119472
You'd be surprised how weird things we have to do sometimes to make it work. But it works, and it's efficient. And it is OOP no matter how much you dont want to believe it.
>>
>>56118963
top kek. Anon with masculinity problems believes political memes make him important.
>>
>>56119452
C-can you explain how that works please
Or direct me to somewhere I can learn it
>>
>>56119499
Christ, just imagine I said a language that forces OOP instead. You can make a purely OOP program in C++. This is entirely beside the point though.
>>
>>56119497
Have you thought about using
ErrorT e (StateT (Map Key Value) IO) s
>>
>>56119499
It is.
>>56119524
>You can make a purely OOP program in C++
Even though it is, you can't

Programming's funny huh?
>>
>>56119553
>tfw it's true
iDontHaveAnyJpgHere.jpg
>>
>>56119524
I mean if I had to make a GUI in C++ I'd use FP where I could

C++ doesn't even have "built-in FP" when it comes to messages and stuff.

And if you use callback functions you're doing a tiny bit of FP

>>56119553
No it isn't.
Where did you get that idea?
>>
>>56119452
What a shitty makefile.

CFLAGS += -O2 -g -Wall -Wextra
LDLIBS = -lm

SRC = $(wildcard *.c)
EXE = program_name

$(EXE): $(SRC=.c=.o)

all: $(EXE)

clean:
$(RM) $(EXE) $(SRC:.c=.o)


This assumes program_name.c exists.
>>
>>56119553
What do you mean, you can't? You're answer better be something other than "main isn't in a class"
>>
>>56118257
Researching NES development so I can make simple online games in C via the expansion port. If you want are interested, hit me up on Tox at 47C60F1297116D059331EEBCBD7D0BD67966ADCCD2506E8329EDA11395F7C310714BFB9F4552
>>
>>56119574
your*
kill me
>>
>>56118316
damn str8
>>
>>56119510
isn't it the same as making a script that type your big gcc line, and then just calling your script to compile ?
>>
>>56119568
C++ is multiparadigm language allowing data abstraction. He is Procedural, Generic AND OOP.
It is not purely OOP like SmallTalk, so you can't make a pure OOP code.
>>
>>56119607
Start over.
Hint: you only need one loop.
>>
File: arrowmath.png (36KB, 400x400px) Image search: [Google]
arrowmath.png
36KB, 400x400px
I need to calculate the direction and speed I need to fire an arrow for a game I am working on, pic related i the scenario. Dont know if this is the best place to be asking this but I only browse g, lgbt, and b so this seemed like my best shot.
Anyone good at maths?
>>
>>56119617
>C++ is a multiparadigm language
read as: "C++ is not an OOP language"

multiparadigm is code for "procedural kitchen sink" btw
>>
>>56119617
>Generic
>paradigm
>>
>>56119619

aight then
>>
>>56119629
>implying generic programming isn't a paradigm
Go back to school
>>56119626
Say what you want. It was developed mainly as OOP language, failed miserably, but is what it is.
>>
>>56119622
>game
These guys might be able to help >>>/vg/agdg/
>>
>>56119082
Did it myself

addmissing :: [String] -> [String]
addmissing xs = addempty (map isthere ['a'..'z']) xs []
where isthere c = any (c `elem`) xs

addempty :: [Bool] -> [String] -> [String] -> [String]
addempty (y:ys) (x:xs) acc
| y = addempty ys xs (acc ++ [x])
| otherwise = addempty ys (x:xs) (acc ++ [""])
addempty (y:ys) [] acc = addempty ys [] (acc ++ [""])
addempty _ _ acc = acc


ugly but it works fine
>>
To all you Haskellfags, how did you learn Haskell? It looks fun. I don't know what I'd do with it, but it looks fun.
>>
>>56119671
I vomited a little.
>>
>>56118316

we need to make dpt great again.
>>
>>56119622
You've got an angle θ from the ground to the direction you fire at, e.g.
./
/θ_


The speed it is in the firing direction and this angle tell us the horizontal and vertical speed

initial x speed = speed cos θ
initial y speed = speed sin θ

You need to tune the y so that it gives you enough time for you to reach the target, i.e.
t = the horizontal distance / initial x speed
yt - gtt = 0
>>
>>56119698
Yeah me too but I cba to think how to elegantly do an autistic function like that
>>
>>56119722
Yeah i understand that feeling.
Sometimes we just have to get shit done.
>>
>>56119622
delta_x = v_x * delta_t
delta_y = v_y * delta_t - (1/2) * g * (delta_t ^ 2)
g * arrow_peak = (1/2) v^2

Three equations, three unknowns.
>>
>>56119671
>>56119698
a_ :: [String] -> [String]
a_ xs = addempty (map isthere ['a'..'z']) xs []
where isthere c = any (c `elem`) xs

_a :: [Bool] -> [String] -> [String] -> [String]
_a (y:ys) (x:xs) acc
| y = _a ys xs (acc ++ [x])
| otherwise = _a ys (x:xs) (acc ++ [""])
_a (y:ys) [] acc = _a ys [] (acc ++ [""])
_a _ _ acc = acc
>>
People have awfully hot opinions about things they don't truly understand.
>>
>>56119760
communism
>>
>>56119760
Hi there!
You seem to have made a bit of a mistake in your post. Luckily, the users of 4chan are always willing to help you clear this problem right up! You appear to have used a tripcode when posting, but your identity has nothing at all to do with the conversation! Whoops! You should always remember to stop using your tripcode when the thread it was used for is gone, unless another one is started! Posting with a tripcode when it isn't necessary is poor form. You should always try to post anonymously, unless your identity is absolutely vital to the post that you're making!
Now, there's no need to thank me - I'm just doing my bit to help you get used to the anonymous image-board culture!
>>
>>56119697
Practice, and online resources
It's really nice to code in

it's not that hard to get started
f :: a -> b
-- the type of f is a function from a to b
f x = y
-- when given x, f will output y

l :: [(Int, Bool)]
--l is a list of (Int, Bool) pairs

act :: IO String
-- act is a procedure that produces a string
act = readFile "myfile.txt"

>>56119671
>>56119753
Why not use the splitter library?
>>
>>56119779
Never heard of it, I'll have a look when I finish this program
>>
>>56119772
Real communism has never been tried
>>
>>56118326
>You're on an anime website
Maybe in 2007. Face it, this site has been invaded by non-chinese-cartoon-watchers. You people are a minority.
>>
>>56119789
Wait nvm
Haskell has a group function in Data.List, that groups by equality
>>
>>56119772

What about it?
>>
File: 1471230424768.jpg (2MB, 2080x1560px) Image search: [Google]
1471230424768.jpg
2MB, 2080x1560px
>>56119791
>>
>>56119832
how was the day, in the freedom land?
>>
>>56119082
Rather than filter use map

>>56119772 >>56119791 >>56119832
Don't start this bullshit again
>>
>>56119671
How can I run this? I have ghc installed.
i.e. what do I write for main? I barely know Haskell, sorry.
>>
>>56119884
in GHCI:

:{
--insert his code here
:}

:{ is multiline input terminated by :}

addmissing ["abc", "def", "geh"]
-- just use your own string list
>>
>>56119884
You can run this with Windows Movie Maker
>>
>>56119884
If you just pop it in a file and don't compile, just load the file into ghci by doing
$ ghci myfile.hs

You should then be able to pop inputs into it by doing (for example)
addmissing ["aa","bb","kk","zz"]


but it's a boring as fuck function to try out, was just to do something specific in my program
>>
>>56119910
Thanks; and I knew what it was supposed to do from the conversation, I just never really got how people tested this (either writing a main or using ghci)
>>
>>56119884
If you really want to write a main for this stuff

main = print somevalue
e.g.

main = print $ addmissing ["a","bb","cZ"]

$ basically just changes the precedence of function application so that it's read as print (admissing [..]) rather than (print admissing) [...]
>>
>>56119910
What is it for? Why not just have an array of 26 integers and increment said integer when it runs across the respective letter?
>>
Anyone here use naive bayes classification before? I'm writing one and trying to come up with some rudimentary string comparison techniques for the comparators.

Obviously .equals() and .contains() are good ones, and I'm using .trim(). Any advice on vague string matching in general? I'll probably implement Levenshtein distance soonish, but for now I'm just think of really simple stuff.
>>
>>56119955
That would be a much better way to do it, thanks
>>
>>56119955
nice catch

>>56119968
Use the state monad with the traversable stuff like for_ to run over the list
>>
>>56119200
>vim and emacs are for people who like the idea of programming more than they actually enjoy programming.
confirmed for doesn't step outside /g/
I know professional programmers who don't rice at all and use vim and emacs.
>>
>>56119855

I cleaned my guns and drove a V8 vehicle that gets very poor fuel economy.
>>
>>56119956
use fuzzy match maybe

example
#include <stdio.h>
#include <ctype.h>

static int fuzzy_match(const char *pattern, const char *str)
{
while (*pattern && *str) {
if (tolower(*pattern) == tolower(*str)) {
++pattern;
}
++str;
}

return (*pattern == '\0');
}

int main()
{
printf("%d\n",fuzzy_match("cute cat","cat"));
return 0;
}
>>
A simple VULKAN project for my working group
>>
>>56119469
The FP version would base itself around functional callbacks to individualize behavior of the GUI components, while the OOP version would subclass the components to provide the differences in behavior.

However, 90% of the C++ project would be spent arguing over style, reimplementing the standard library, and downloading boost, while 90% of the OCaml project would be spent trying to find graphical bindings or communicating through a shoddy FFI
>>
>>56120016
Why do you trip? Desperate for attention? It doesn't benefit you at all and you've contributed nothing to this thread.
>>
>>56119981
this might be useful if you do go this way
updateIndex i f xs = front ++ (f item) ++ back
where (front,item:back) = splitAt (pred i) xs


(updateIndex 3 (const "hello")) ["a", "b", "c", "d", "e"]
-> ["a", "b", "c", "hello", "e"]

(updateIndex 3 (\a -> a ++ a)) ["a", "b", "c", "d", "e"]
-> ["a", "b", "c", "dd", "e"]
>>
>>56120066
>you've contributed nothing to this thread.

Have you?
>>
>>56119570
how does this account for includes and src being in different folders?
>>
>>56120073
whoops this doesn't work for 0, add this before
updateIndex _ _ [] = []
updateIndex 0 f (x:xs) = (f x) : xs
>>
>>56120075
yes. you wouldn't know because i'm anonymous retarded trip faggot
>>
>>56120106
>yes.

I don't bloody think so.
>>
>>56120118
>saying bloody when you aren't british

kys
>>
>>56120118
How would you know?
>>
>>56118257
https://en.wikipedia.org/wiki/Linguistic_relativity#Programming_languages

>APL programming language originator Kenneth E. Iverson believed that the Sapir–Whorf hypothesis applied to computer languages (without actually mentioning it by name). His Turing award lecture, "Notation as a tool of thought", was devoted to this theme, arguing that more powerful notations aided thinking about computer algorithms.[74]

>The essays of Paul Graham explore similar themes, such as a conceptual hierarchy of computer languages, with more expressive and succinct languages at the top. Thus, the so-called blub paradox (after a hypothetical programming language of average complexity called Blub) says that anyone preferentially using some particular programming language will know that it is more powerful than some, but not that it is less powerful than others. The reason is that writing in some language means thinking in that language. Hence the paradox, because typically programmers are "satisfied with whatever language they happen to use, because it dictates the way they think about programs".[75]

Well /g/, which language makes me the smartest programmer? Is Haskell the most autistic and logical of all the languages?
>>
>>56120141
>Is Haskell the most autistic and logical of all the languages?
It's not perfect but it's a start
Hopefully if Haskell picks up we'll get better performance and less overhead
>>
>>56119933
The interpreter is really fucking powerful, without it debugging Haskell would be intolerable.
You can just open it up, type check things, inspect function type signatures etc.
For instance, you forget the name of that standard library function?
> :t intercalate
intercalate :: [a] -> [[a]] -> [a]
> :t intersperse
intersperse :: a -> [a] -> [a]


You forget the argument order?
> :t elem
elem :: (Eq a, Foldable t) => a -> t a -> Bool
>>
>>56119753
aren't you suppose to use a', then a'', etc.
>>
>>56120158
what's the purpose of haskell?

when you do
elem :: (Eq a, Foldable t) => a -> t a -> B


or whatever the fuck is this mumbo jambo, its calling thousand and thousand of lines just to do a simple task

i dont get it
>>
>>56120185
the joy of programming

it's a general purpose language

start with this
http://www.seas.upenn.edu/%7Ecis194/spring13/lectures.html
>>
>>56120185
What's the point of any language that isn't C, then? I imagine Python is worse with the "calling thousands and thousands of lines just to do a simple task" thing.
>>
>>56120185
what language do you use
>>
>>56120185
>"abstraction is bad because I said so!"
>"performance is the only thing that matters! the only thing!!"
>>
>>56120201
>>56120212
>>56120213
>>56120232
why not making a built in function that prints fizzbuzz?
do_fizzbuzz()
>>
>>56120225
i thought that thread was on /o/

go the fuck away
>>
>>56120249
sure, why not?
lets call it main()
>>
>>56120249
shhhh stop teaching them how to actually create a 4chan programming language
>>
>>56120249
because you can reuse those generic functions and to compose new ones
>>
>>56120232
>>"performance is the only thing that matters! the only thing!!"
I don't get this. you fags are constantly talking about muh efficient algorithms... yet you deny that performance is the thing that matters the most. explain please.
>>
linux x64 nasm , i cant get this to work


section .text
global _start
_start:
xor rax,rax
xor rbx,rbx
xor rcx,rcx
mov rax,46h
int 80h



i get segmentation fault msg
gdb gives the same output
>>
>>56120276
the sysop would like a word with you

electricity and time are both unfree
>>
>>56120288
>x64
>int 80h
>>
{-# LANGUAGE LambdaCase #-}
import System.Environment (getArgs)
import Data.List (unfoldr, sort)
import Data.Char (isAlpha, toLower)

putLines = mapM_ putStrLn
main1 f = putLines . f . read
main = getArgs >>= \case
("alphas" : xs) -> print . alphas . unwords $ xs
["check", x] -> main1 check x
["cross", x] -> main1 (plot cross) x
["fizz", x] -> main1 (flip take fizzbuzz) x
_ -> putStrLn "What!?"

-- Alphabet filter >>56119082
alphas text = map ((`filter` text) . (==)) ['a'..'z']


-- Checkerboards
check n = take n `map` take n check'
check' = tail `iterate` cycle " #"

-- Cross-Plot
cross x y = abs x == abs y
plot f n = range (range . point)
where
range = flip map [-(n-1)/2 .. (n-1)/2]
point y x = if f x y then '*' else ' '

-- Fizzbuzz
fizzbuzz = zipWith max nums (fizz /++ buzz)
where
nums = map show [1..]
(/++) = zipWith (++)
fizz = 2 !? "fizz"
buzz = 4 !? "buzz"
n !? w = cycle (replicate n "" ++ [w])


{-
Prelude> :l blub.hs
[1 of 1] Compiling Main ( blub.hs, interpreted )
Ok, modules loaded: Main.
*Main> :main check 8
# # # #
# # # #
# # # #
# # # #
# # # #
# # # #
# # # #
# # # #
*Main> :main alphas jackdaws love my quartz sphinx
["aaa","","c","d","e","","","h","i","j","k","l","m","n","o","p","q","r","ss","t"
,"u","v","w","x","y","z"]
*Main> :main cross 7
* *
* *
* *
*
* *
* *
* *
*Main> :main fizzbuzz 15
What!?
*Main> :main fizz 15
1
2
fizz
4
buzz
fizz
7
8
fizz
buzz
11
fizz
13
14
fizzbuzz
*Main>
-}
>>
File: e09.png (41KB, 235x236px) Image search: [Google]
e09.png
41KB, 235x236px
>languages where the assignment operator is <- or :=
>making you press shift + other keys for the most common operation

Bad UX t.b.h.
>>
File: 1471126131100.jpg (22KB, 152x267px) Image search: [Google]
1471126131100.jpg
22KB, 152x267px
>>56118257
A or B? C# btw:
A:
cmp = tree._value.ID.Equals(newItem._value.ID);

B:
cmp = tree._value.ID == newItem._value.ID;
>>
Write a piece of code to output the line number of the print / output statement itself
>>
>>56120249
If I ever am allowed to contribute to an official standard library, I'm going to add that.

>>56120263
generic fizz buzz
class Monoid f => Fizzable (f :: * -> *) where
fizz :: f
buzz :: f
noFizz :: Int -> f

fizz1 :: (Integral i, Fizzable f) => i -> f
fizz1 i = case (i `rem` 3, i `rem` 5) of
(0,0) -> fizz <> buzz
(0,_) -> fizz
(_,0) -> buzz
(_,_) -> noFizz (fromIntegral i)

fizzbuzz :: Fizzable f => [f]
fizzbuzz = fizz1 <$> [1..100]


>>56120276
efficiency matters when it matters and it doesn't matter when it doesn't matter
>>
>>56120349
B
>>
>>56120338
import Data.Function (on)
cross = (==) `on` abs

plot/point
point y x | f x y = '*'
| True = ' '

>>56120341
>assignment
>most common operation
learn2program

>>56120349
A looks retarded, but I don't know how deeply C# is inspired by Java
>>
>>56120341
>Haskell
>assignment most common operation
shiggy my diggy
>>
>>56120341
>making assignments need purposeful entries

>two fingers literally hard to move

go sell sea shells
>>
>>56120365
#include <stdio.h>
int main(void) {
printf("%d\n", __LINE__);
return 0;
}
>>
>>56120373
>efficiency matters when it matters and it doesn't matter when it doesn't matter
how convenient
>>
File: Screenshot_2016-08-16_22-36-31.png (81KB, 402x168px) Image search: [Google]
Screenshot_2016-08-16_22-36-31.png
81KB, 402x168px
>>56120365

>>56120349
B, I don't see why you'd go A over that
>>
>>56120405
I think he's asking if they're the same in C#
>>
>>56120349
I want to marry Yun

Answering your question, B
>>
>>56120349
C# overloads the == operator, so they are the same
>>
>>56120314
i get the same error with sysenter
>>
>>56120404
>fine tuning parts of your code that aren't bottlenecking performance, at the cost of productivity and sanity
>>
>>56120288
What are you even attempting here? Because as far as I can tell your attempting to call sys_setreuid16
>>
>>56120447
*you're
>>
Kay, B will b, ty baes.
>>
>>56120447
setreuid(0,0)
this is just a part, i deleted the other one till i can make this work
>>
>>56120442
>>fine tuning parts
>not using a performant languages/package/frameworks/... from the start
>>
>>56120365
print(1)


>>56120288
>>56120456
Are you running the asm as root? If you aren't you'll probably get segfault because the asm is supposed to make you root
>>
>>56120385
>on
Meh. The definition of cross reads better as-is I think.
>point
But that's two whole lines! Better would be:
point y x = Data.Bool.bool ' ' '*' (f x y)
>>
>>56120486
point = (Data.Bool.bool ' ' '*') . f
>>
>>56120476
>he doesn't know that Haskell can be as fast as C
>he has stockholm syndrome from using C/C++
>he wants to sacrifice the productivity of using more powerful languages because he thinks the performance of his fizzbuzz code matters
languages are a tool.
>>
>>56120477
yea , root
>>
Why can I not use int number in this way, and also, can't use toString to make it a string?

package org.waikato.comp204;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
import java.util.Random;

// Your Project JavaFX code goes here
public class Project extends Application {

public void start(Stage primaryStage) {

Random rand = new Random();
int number = rand.nextInt();

GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.setPadding(new Insets(25, 25, 25, 25));
grid.setPrefHeight(600);

ColumnConstraints column = new ColumnConstraints(295);
grid.getColumnConstraints().addAll(column, column, column);

TextArea output = new TextArea();
output.setEditable(false);
grid.add(output, 2, 0);
grid.setGridLinesVisible(true);

Button btn = new Button("Make a number");
grid.add(btn, 0, 0);
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
output.appendText(number);
}
});

Scene scene = new Scene(grid, 900, 600);
output.setPrefSize((scene.getWidth() / 3), scene.getHeight());
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();

}
public static void main(String[] args){
launch(args);
}
}
>>
>>56120486
>>56120494
oh wait, nvm i am retarded
point (y,x) = (Data.Bool.bool ' ' '*') . uncurry f
but that's worse
>>
>>56120494
Cool type error, bruh.
point = (bool ' ' '*' .) . f
>>
File: 1461192120584.gif (2MB, 320x235px) Image search: [Google]
1461192120584.gif
2MB, 320x235px
>>56120504
>import javafx.application.Application;
>import javafx.event.ActionEvent;
>import javafx.event.EventHandler;
>import javafx.geometry.Insets;
>import javafx.geometry.Pos;
>import javafx.scene.Scene;
>import javafx.scene.control.Button;
>import javafx.scene.control.TextArea;
>import javafx.scene.layout.ColumnConstraints;
>import javafx.scene.layout.GridPane;
>import javafx.stage.Stage;
>import java.util.Random;

>>56120520
> .).
nice
>>
>>56120499
Do you have an exit syscall afterwards? Try stepping through it in gdb.
>>
>>56120477
but even if i go to normal user i still get the same error
>>
>>56120499
Make sure you're calling sys_exit
>>
>>56120531
I'm building using javafx, I need an answer why I can't appendtext using a textarea. Only accepts strings and in my instance I can't .toString it.
>>
>>56120531
f . g = \x -> f (g x)
-- therefore:
\x y -> f (g x y)
= \x -> f . g x -- definition of (.)
= \x -> (f .) (g x) -- operator section
= (f .) . g -- definition of (.)
>>
>>56120555
>>56120537
i already tried
>>
What's the closest thing to magic you've ever seen?
>>
>>56120603
bit shit is magic to me, like fast square inverse
>>
>>56120531
Please I need answer to this issue.
>>
>>56120603
Programming.
>>
>>56120341

> languages that have (value) -> (var) instead of (var) -> (value)
>>
>>56120603
>>56120624
>fast square inverse
This
Actual sorcery
>>
>>56120693

not really though

it uses newtons method and it takes advantage of the fact that floats are stored in a form of scientific notation, which can be accessed faster with pointers
>>
>>56120727
I understood 'science something pointers'
>>
>>56120727
Obviously it isn't really magic. It's something that is seemlingly magic, i.e. the math is not easily deducible from the implementation.
>>
>>56120727
>which can be accessed faster with pointers
Sorry, can I have that again, but with less retarded? And that doesn't explain the 0x5f3759df.
>>
>>56119570
> not using gcc -MD to autogenerate header dependencies
why do so few people actually know how to use make?
also:
> using = instead of :=
>>
If number is an int, why cannot do output.appendText(number);?
>>
>>56120603
after recreating heap sort algorithm in Human Resource Machine i was once reminded how brilliant that algorithm is.
>>
File: 300px-NewtonIteration_Ani.gif (30KB, 300x214px) Image search: [Google]
300px-NewtonIteration_Ani.gif
30KB, 300x214px
>>56120752

what they do is they calculate the derivitive first and then do this
>>
>>56120773

Ok stupid, let me explain

1. the 0x5f3759df is just a guess for the newton approximation. the picture I posted here >>56120816 needs a starting point.

2. normally computers have a floating point processor. it converts numbers to and from a form of scientific notation when they are accessed or stored. With pointers, you can get past the floating point processor and just get the scientific notation.

Keep in mind inverse square root = x^-.5
>>
>>56120603
Fourier transforms
>>
>C++
Ok so I have a derived class and I have overloaded a base class function. Now I want to call that at the end of the function i wrote to overload it.
Basically:
class A{
virtual void Foo(int param);
}

class B{
void Foo(int param);
}

void B::Foo(int param){
//Do stuff
A::Foo(param); //on 'this' object

}
>>
>>56120922
what's the problem?
>>
>>56120603
Math. Math is insane. ABSOLUTELY INSANE.
They do the craziest shit imaginable in math.
>>
Finished my program (https://projecteuler.net/problem=59 if anyone cares)

and remade my shitty function to look a lot nicer, thanks for the suggestions.

The whole thing could be tidier and faster but it's 5am so fuck it

addmissing :: String -> [String] 
addmissing input = zipWith replicate (freqchars (replicate 26 0) input) ['a'..'z']

freqchars :: [Int] -> String -> [Int]
freqchars acc [] = acc
freqchars acc (x:xs) = freqchars (y ++ (z+1) : ys) xs
where charval = ord x - 97
(y,z:ys) = splitAt charval acc


http://pastebin.com/5tMej10s
>>
>>56120941
Are you saying this works? Like, If I type A::Foo(param) in a member function of a derived class it calls the function of the base class?

I didn't think it worked like that because I never reference this.

Or if you were just asking what the problem was. Basically I want my derived class to add a few steps before it calls old function. That's now overloaded so this->Foo(param) would be a recursive call, that's not what I want.
>>
File: 5828321.jpg (233KB, 2480x1691px) Image search: [Google]
5828321.jpg
233KB, 2480x1691px
>netbeans uses 1gb of ram
should i even bother using this or was my professor just memeing on me
>>
>>56120951
Actually I refactored it to just use the frequency of the chars instead of the actual chars, it's not I want to die tier now

also any haskellers used hdevtools and hlint with vim/emacs? It's super comfy
>>
>>56121056
Anything Java uses a shitload of ram
The meme is not Netbeans, it's Java itself
>>
>>56121056
For what language?
Most IDE's are terrible. But the convenience of having a good GUI for a debugger is big.

I know newbies like to think of programs as this analytical process they can figure out without inspection. And you can do that. But when you don't it can be a real issue if you don't have good insight into what's going on.
>>
>>56118458
looks pretty trivial to me, there's no assignment to str in parse_hex or hex_value
>>
>>56121122
java/c++
>>56121106
makes sense since every java program i've used that requires good hardware was always a bad experience
>>
Just finished my first successful test of my home brew diagnostics application for my 2003 Wrangler. It uses J2534 and can read proprietary faults and data, and do diagnostic tests like turning off injectors, commanding EGR valve, and misfire monitor. Eventually I'm going to add live graphing support for the data.

Why? Fuck you that's why.
>>
>>56120996
Doing A::Foo() is how you access member functions of the base class, works for constructors too.
>>
>>56121157
I don't understand anything you said but congratulations anon
>>
>>56121157
>Why? Fuck you that's why.
You on your period or something?
>>
File: 1471092122831.jpg (84KB, 857x463px) Image search: [Google]
1471092122831.jpg
84KB, 857x463px
>>56121157
That's really fucking cool, was it difficult?
>>
>>56121157
Ah yes
EGR valves
>>
how can you get experience on things that require huge distributed computing networks (things like ElasticSearch) on your own? or is that the kind of thing you pick up in the work place
>>
>>56121248
No-one here has a job
>>
>>56120951
Dude, what. See >>56120338.

addmissing text = map ((`filter` text) . (==)) ['a'..'z']


If you want counts then add
length .
before the filter bit.
>>
For some reason, when I edit a single .cs file in Visual Studio (outside any project) the editor doesn't shows any warnings/errors in my code.
Has anyone experienced something similar?
>>
>>56121162
>access member functions of the base class
Ok. Cool. I did not know that.
Is this syntax an implicit "this->A::Foo()"? or is there some magic here.
>>
>>56121187
It's a sign of affection bruh

>>56121190
Kinda. Chrysler's protocol is not very well documented, and every time you want to request data (like your vehicle speed or engine RPM) the engine computer switches to a higher baud rate. When you want to do anything else you have to drop the baud back down, which was kind of a bitch to code in a multi threaded environment. Like if the user tries to turn off an injector, the data thread must be stopped and the module returned to "normal" state, then the command can be sent and the module can be put back into high speed mode. Somehow all this can happen without the computer vomiting and dying.
>>
File: re zero rem crying.jpg (253KB, 1920x1080px) Image search: [Google]
re zero rem crying.jpg
253KB, 1920x1080px
>>56118316
anime has feelings too
>>
>>56121285
Ok that's pretty cool. I was thinking of doing something like that but wasn't sure how to get all the filters to combine. I'm too tired.

>>56121311
Is it possible to fuck anything up if you have a bug or don't know what you're doing?
>>
>>56121157
Did you use

https://www.amazon.com/Vehicle-Computer-Reader-Diagnostic-Scanner/dp/B00Z3NZBSK


I have a Porsche Cayan and would like to do something similar.
>>
Working on bacterial growth sim for an internship at uni. Currently working on the algorithm that will alter the speed at which bacteria will grow based on pH, temperature, water concentration, climate, etc.
>>
>>56121466
Neat! That's really awesome. Are you getting paid for your internship?
>>
>>56121364
Not when reading data, but when running tests you can actively fuck things up. On GM vehicles for instance, you can force the ABS motor on (with the engine off). For context, the ABS motor is the thing that keeps your tires from locking up on ice. Now, if your app crashes while doing such a thing, the motor will stay on... Forever. Like, turn the key off, and it will continue to be running the motor until molten metal is dripping off of it, or the "stop" command is sent.

What I'm trying to say is, holy shit yes.
>>
>>56121487
yep, $12/hr
>>
>>56121409
No, the Chrysler proprietary protocol is not OBD-II compliant. I use the official Chrysler adapter because I work in diagnostics and have such hook ups.

Creating an OBD-II app would be fun, just keep in mind you won't be able to run tests.
>>
I am so proud of this
*Main> putStrLn (showDoubleArray (avgEveryThree [1, 5, 4, 7, 9, 17, 0, 5, 6]))
3.3333333333333335
11.0
3.6666666666666665

I am becoming a Haskellfag.
>>
>>56121836
putStrLn $ showDoubleArray $ avgEveryThree
>>
>>56121857

(read <$> getLine) >>= (putStrLn . showDoubleArray . avgEveryThree)
>>
>>56121857
Is it common practice to do that?
>>
>>56121338
>posting thirsty submissive turbomaid in a programming thread
for fuck's sake at least use aoba
>>
>>56121876
avoiding parentheses is the main use of $ (other than passing application to higher order functions), if you mean this specific example it's a style choice
>>
>Haskell without 3 dozen non-standard GHC extensions and another 3 dozen non-standard packages

Why?
>>
Just finished watching thenewboston's C tutorials and feel like I absorbed the information pretty well, what should I move onto next?
>>
>>56121981
GHC/Haskell forall something. different
>>
>>56121981

Learning C11.

Unfinished but pretty good book.

http://icube-icps.unistra.fr/index.php/File:ModernC.pdf

WIsh the guy would update it. It's been almost a year but stuff like that does take a while to write.
>>
Im playing with racket. So far i love it. All the lispy goodness with actual libraries. And its not as annoying as haskell
>>
>>56122134
I think racket is more annoying than haskell... but just my opinion desu.
Racket is pretty cool, always nice to have a useful lisp.
>>
>>56122161
I like haskell and used it pretty much but that focus on purity is tad bit annoying imo, useful for sure but annoying.
Useful lisp, i have no idea why i never checked racket before, messed with cl and scheme but never racket
>>
>>56121981
Make projects? What kind of question is that?
Make an IRC bot, a TCP chat, a 2D game, a text adventure, an interpreted language interpreter, whatever.
>>
>>56120951
>>56120951
>>56120951
Here, I made your code a little less godawful. Why in the hell are you doing this:
f | blah blah = True
| otherwise = False

-- when this is equivalent:
f = blah blah


http://lpaste.net/4181564113387782144
>>
>>56120504
try String.valueOf(number)
>>
>>56120783
append text probably wants a string. (String)number or number.toString() or String.valueOf(number)
>>
NEW THREAD!!

>>56122356
>>56122356
>>
>>56122361
thank you hime
>>
How much math do you need to be a competent programmer??
>>
>>56120185
If you compile it with -O2 the mumbo jumbo is just fucking 20 machine instructions.
>>
What kind of plans should I make for projects besides UseCase?

I can't stand UML diagrams, so it's banned. What are the other options?
>>
can someone ENLIGHTEN ME

could you write hello world in c without stdio
>>
>>56122410
a good one? a lot
>>
>>56122195
I guess I should have phrased that differently, I assume theres still plenty to learn about C, I don't feel as though I could do anything more than a text based game as the tutorials on thenewboston don't cover GUI's in any way, just how the basic things in the language work
Thread posts: 314
Thread images: 18


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