[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 15
File: dpt.png (39 KB, 180x193) Image search: [Google]
dpt.png
39 KB, 180x193
What are you working on, /g/?
>>
>>51601187
I fucked up

Previous thread: >>51595491
>>
>>51601187
SeconD
>>
>>51601187
>Image for ants
>Forgot old thread link
You really fucked up.
>>
Fourth for Egison best language!
>>
File: dd.jpg (199 KB, 1280x965) Image search: [Google]
dd.jpg
199 KB, 1280x965
5th for D!
>>
File: neon paradise.png (4 MB, 1543x965) Image search: [Google]
neon paradise.png
4 MB, 1543x965
Reposting from old thread

I'm working on an image editor for glitch art.

We just released a new version, and I would be eternally grateful if you guys would check it out.
Feedback is greatly appreciated, especially regarding usability.
Something you didn't like, something that stood out, unexpected results, etc.

Link:
>glitchy.codemouse.dk

Pic is an image I made with the program.
>>
Friendly reminder that writing a program takes 50x longer than it would in any other language because there are no libraries to be found.
You have to write EVERYTHING yourself.
>>
this has bothered me for quite a while. in fact, I've never been sure how it is supposed to be done: if you have a long task, how do you decide how to separate it in smaller functions, and what arguments to pass? the less, the better? just do it and see if you need to separate it later?

I need to download a file, but restrict it depending on file size and MIME type. and I can check both restrictions while dowloading, by checking the headers (which I suppose should not be trusted... but that's another topic), and when the download is finished, by checking the size and mime-type of the file that has been downloaded.
the thing is, I don't know if I should put all of this in one function, or two or more functions. if I put it in one, I kinda lose control over what is done to the file, plus I will probably have to separate it in two parts to not reuse code, and if I put it in >1, I have to reuse objects from one function to the other, and pass many more arguments...

anyway, this was just an example. what are factors to decide how to write a function/method?
>>
>>51601246
Thankfully there is a language with a girl in her logo.
>>
>>51601260
wat
>>
How do you guys take on big projects?
I recently started working a fairly large project (writing a network stack from scratch).
To stay focused, I created a TODO file with at the moment somewhere around 100 small goals.
Previously I had the problem that I lost interest after a few weeks, but I really want to build and finish this.
>>
>>51601291
SCRUM board.
>>
>>51601291
>a few weeks to write a network stack
you were never meant to be a programmer
>>
>>51601256
>No source code
Sorry, I'm not downloading your malware.

>>51601270
>what are factors to decide how to write a function/method?
Intuition. Good taste.
Making something a function that could easily be done as an if statement is overkill, but if there is any real computation involved or it's conceptually different to what you're doing, make it a different function.
Also, I try to make as many functions as I can to be pure (with maybe the exception of passing a pointer in to a buffer).
>>
>>51601218
if you are getting neetbux, you probably don't need too much money anyway, and your government probably won't bother suing you for $100/mo in taxes
anyway, if you really were interested in working, you'd be trying to find info... not asking 4chan
>>
>>51601291
>writing a network stack from scratch
Have fun reading dozens of very large RFCs. TCP gets very complicated when optimisations are thrown in.
>>
Threadly reminder that the act of writing computer instructions is not coding. The proper term is programming
>>
>>51601364
The government would throw you in jail because defrauding the government is a felony. Moreover, your neetbux during that period would be revoked and you would be liable for additional fees.
>>
>>51601327
If it takes you longer than a day to write your own web server then you're incompetent.
>>
Thinking about writing my own relational database software in C. Good idea/bad idea?
>>
>>51601327
what do you mean? it should take less, or more time?
>>
>>51601463
it shouldn't take you 2 weeks is what i'm saying
>>
>>51601363
>Sorry, I'm not downloading your malware.

Dang sarnet, I almost had you!
You are getting too clever for me
>>
>>51601445
>more than an hour
FTFY
Literally
>open socket
>spawn thread
>serve something
>>
>>51601445
That's just the application layer. What about all of this shit below it?
>>
>>51601424
Isn't coding a proper subset of programming since coding refers to typing as opposed to using something like Scratch or a dataflow language?
>>
>>51601494
Are you asking how long it takes to implement an operating system in order to implement an http server?
>>
>>51601187
Working on some simulations in ns-3 and an Android app.
>>
>>51601445
>network stack
retard
>>
>>51601505
Coding literally is not a word.
>>
Why doesn't Racket have a function to read a char WITHOUT the user pressing enter?
>>
>>51601388
please, explain
>>51601327
>>51601479
>>51601445
>>51601488
>>51601494
did these guys read every single RFC out there...?
>>
>>51601187
Daily reminder that Julia is more elegant and faster than haskell or any lisp.

maxSum(lists) = map(x -> max(x...), lists ) |> sum
>>
>>51601535
Why do you need to reinvent a very carefully engineered wheel?
>>
>>51601538
>Jewlia
>>
AJAX?
>>
File: 4CNvf6m.png (39 KB, 771x659) Image search: [Google]
4CNvf6m.png
39 KB, 771x659
>>51601541
Kill yourself

>>51601535
They are fucking retards
>>
>>51601326
Seems interesting, I've used kanban in some projects before.

>>51601327
What do you even mean?
I'm going to build everything from the standards, implementing routing, something like netfilter (firewall, NAT, mangle), a socket API, routing algorithms, etc.

>>51601507
The only thing I'm going to use from the OS is the raw socket interface that gives the raw, unprocessed standard 802.1 Ethernet packets.
No networking will happen in the kernel, everything should happen in userspace.

>>51601388
That's part of the plan. Currently reading the IEEE 802.1 and 802.2 standards for Ethernet, LLC, bridges, etc.
I don't really care how much time it will take, I just want to understand everything.
Reading, implementing and then writing about it.
>>
>>51601548
Aren't you a clever one?
>>
>>51601575
>I'm going to build everything from the standards, implementing routing, something like netfilter (firewall, NAT, mangle), a socket API, routing algorithms, etc.

Why?
>>
>>51601582
Friendly reminder that reinventing the wheel is a good thing, contrary to the baseless FUD most code monkeys insist on perpetuating.

Doing it yourself allows you to learn about the chosen problem domain and thus become a better programmer. It adds to the amount of possible solutions to a given problem and thus is always valuable. You are also very likely to end up with a better library or application than existing ones, since you aren't constrained by backwards compatibility and, due to today's free and open source software world, you can learn from the past mistakes of others. You are also free to choose the implementation specifics, such as the language of implementation.

>b-but reinventing the wheel is bad

Are you against innovation, evolution and choice? Reinventing the wheel is crucial when the wheel is actually part of your core business. This is a known fact in all engineering professions. Perhaps the term "reinvent the wheel" is the source of the problem. Let us say "reengineer the wheel" instead.

Don't take it from me. Here are some sources that will enlighten you:

http://www.obxerve.com/en/article/reinventing-the-wheel-can-be-good/

http://www.codinghorror.com/blog/2009/02/dont-reinvent-the-wheel-unless-you-plan-on-learning-more-about-wheels.html

http://lea.verou.me/2012/04/in-defense-of-reinventing-wheels/

http://www.joelonsoftware.com/articles/fog0000000007.html

https://en.wikipedia.org/wiki/First-mover_advantage#First-mover_disadvantages

http://timkastelle.org/blog/2012/01/please-reinvent-the-wheel/
>>
File: 1443717897495.jpg (18 KB, 279x246) Image search: [Google]
1443717897495.jpg
18 KB, 279x246
>>51601538
maxSum = sum . fmap max
>>
>>51601570
>They are fucking retards
and I agree. these fucking retards talk fast... I wonder if they have ever made anything, at all

>>51601541
did you even read the posts?
>a network stack from scratch
>your own web server
surely you can program things from scratch in a few hours just fine, anon :^)
>>
>>51601363
>Intuition. Good taste.
>Making something a function that could easily be done as an if statement is overkill, but if there is any real computation involved or it's conceptually different to what you're doing, make it a different function.
>Also, I try to make as many functions as I can to be pure (with maybe the exception of passing a pointer in to a buffer).
thanks.
in this example I gave, what bothers me is that I'd either have to pass a *FILE, or I would have to open the same file twice. the first solution seems to be potentially prone to horrible bugs, the second seems stupid... and that's how I get stuck when trying to solve little problems. I don't know if there is something wrong with me, or if this is really important at all

>>51601270
anyone else?
>>
>>51601691
>the first solution seems to be potentially prone to horrible bugs
Not really. It's also idiomatic, you should have your functions doing as little resource management as possible.
>>
>>51601520
No language does.
>>
>>51601538
Daily reminder that Julia is beyond broken.
http://danluu.com/julialang/
>>
>>51601582
Because I can.
But mostly as a research platform, because scripting eg an ECMP routing or custom queueing algorithm in Python is easier than having to write a kernel module. So it is mostly for prototyping, before porting it to a lower level language
And it's also for understanding how *everything* in the network stack works.
>>
>>51601620
>this is what cmen believe
>>
File: 1394607712758.jpg (7 KB, 225x225) Image search: [Google]
1394607712758.jpg
7 KB, 225x225
>>51601797
>Update: this post was edited a bit to remove a sentence about how friendly the Julia community is since that no longer seemed appropriate in light of recent private and semi-private communications from one of the co-creators of Julia.
>>
Should I put the parser generated by a parser generator into my repo or make a script to generate it when building the program?
>>
>>51601849
Always makes me laugh.
>>
>>51601881
You should include the input to the parser generator instead; the generated parser should be treated as an object file (more or less). It's the same as if you have template files or build-time constant.
>>
File: for_free2.jpg (64 KB, 748x752) Image search: [Google]
for_free2.jpg
64 KB, 748x752
>>51601256

I did some glitch art with my editor.
>>
>>51601881
Generate it.
>>
>>51601520
> Why doesn't Racket have a function to read a char WITHOUT the user pressing enter?
Read a char from where? And what is this "user" of which you speak?

Standard input might be a file, pipe, socket, or device. A device might be a terminal or some other device.

The language itself wasn't designed specifically for interacting with a user via a terminal so it isn't going to automatically start messing with standard input to facilitate that case.

On Unix, the terminal driver doesn't pass terminal input onto the process until either Enter/Return or Ctrl-D is pressed unless the terminal is in raw mode (and most shells will automatically put it into canonical (non-raw) mode before executing any program because that's what programs expect).

The main reason for this is so that you can use backspace (or Ctrl-W or Ctrl-U) to edit the input before submitting it (which can't be done if the driver is passing each character to the program as it's entered).

Programs which want "raw" terminal input either use the termios functions (tcsetattr etc) to configure the terminal driver, or use curses to deal with that (and a lot of other stuff besides).
>>
>>51601797
None of that stuff applied even when the post was written, that guy is just some butthurt blogger.
>>
>>51601988
>d-d-d-damage control!
All that stuff still applies to this day.
>>
>>51601246
Is D a meme? I'm quite new here, I don't know D and I can't understand if all those people who mention it are serious or just joking...
>>
How childish do you have to be to deliberately pretend like your language doesn't have shortcomings?

I've got an idea: post your favourite language and something(s) you dislike about it.
>Haskell
>Monads can't be defined by join instead of >>=
>an instance of Applicative isn't automatically derived for every Monad, likewise for Alternative/MonadPlus
>uses :: instead of : for type annotation
>>
>>51602095
D is a meme language
the only people that defend it are NEETs that have never built any real world applications
>>
>>51602095
D is probably pretty good but it's a little bit obscure. There's not too many major projects in D, whether enterprise or free software.

If you need something like D but want to be taken seriously, you pretty much have to use C++ and suck it up.
>>
I have just implemented another system call for my kernel, and have just discovered that it and about 2 other system calls are not correct in all circumstances. Why? Alignment Exceptions!

When you have
1.) An architecture that doesn't like grabbing words from unaligned addresses
and
2.) A language that determines string length from a word in front of the string, rather than null termination

Trying to grab filename substrings the C way is... needless to say, bad. Fuck me, I'm going to have to redesign some code to COPY INTO A BUFFER
>>
>>51602095

It's a meme, but not all memes are bad. Some of them are very enjoyable.
>>
>>51602095
It's a 10/10 would fuck again language
>>51602125
C
Shitty strings
Very little libraries
>>
>>51602125
>C
The entire preprocessor is complete shit, and macros are so bad that they are unusable.
>>
>>51602095
it's a meme, and it's mostly the same small group of people shilling it
>>
>>51602179
>very little libraries
once you go the C route, you might as well reinvent everything yourself.
>>
>>51602158
>A language that determines string length from a word in front of the string, rather than null termination

You say that like it's not leagues better than null termination.
>>
>>51602125
java
can't turn off bounds checking
no free optimizing AOT compiler for windows and linux
that's about it
>>
>>51602283
>that's about it
>>
AJAX?
>>
>>51602283
>java
do you hate yourself?
>>
>>51602301
FEYENOORD
>>
>>51602283
>that's about it

m9...
>>
>>51602257

The problem is that this means that strings must be on word aligned addresses.
>>
>>51602335

That's true, but still.
>>
>>51602293
>>51602302
>>51602334
nice meme
>>
>>51602371
t. Alberto Barbosa
>>
>>51602158
do it the Go way?
http://blog.golang.org/slices
http://blog.golang.org/strings
>>
>>51602371
Enjoy not being able to pass primitives by reference
>>
>>51602371
java is absolute shit
>>
>>51602393
big whoop wanna fight about it

for barely useful things like that i have C++ anyway
>>
>>51602402
epic
>>
>>51602417
>i-it's not that big of a deal anyway
>so what if my language can't do basic shit other languages can
>>
>>51602125
>F#
>a lot of checks that could be done in the compiler end up deferred to runtime (I assume this is due to the extensive .NET / C# interop needs?)
>calling function syntax unpredictable (should I tuple this, or is it F# native?)
>constructing algebraic datatypes composed of records has pretty redundant syntax
>
>>
Oh god templating linked list functionality in c++ is an absolute nightmare
>>
>>51602435
name 3 good reason to use java
>>
Why does C have so few libraries?
>>
daily reminder that functional programming is best used in imperative languages
>>
>>51602454
Not really
>>
>>51602466
I just wish more imperative languages would realize the benefit of a type system that also quantifies effects.

Which is why I'm working on my language. Functional and referentially transparent, but runs like C in pretty much every other way.
>>
>>51602454
I assume you mean a stack based link list that stores types and not objects.

Otherwise, you're a failure
>>
>>51602462
Are you kidding? C has fuckloads of libraries.
>>
>>51602125
>OCaml
>still no real typeclass support
>ugly parametric polymorphism syntax: must be
('a, 'b) x
instead of
'a 'b x

>type constructors aren't curried
>type constructors can't even be curried with GADTs
>>
>>51602490
I hope one day it'll be the second best, just below D
>>
>>51602500
Yeah? Name 5.
>>
>>51602530
stdio
stdlib
time
math
string

slacker
>>
>>51602516
I'm going to beat D.
>>
>>51602462
C is supposed to be a small language. You could add more, but then it would eventually be C++.
>>
>>51602556
Whose?
>>
>>51602353

I dunno man, I just guess I find null termination easier to work with. Besides, you can always implement your own string system easily within a null terminated one.
>>
>>51602125
>guile
Shit memory management (lol boehmgc) which leaks ridiculously fast, unbounded, in any memory-intensive set of operations.

>racket
Almost every error is a runtime error unless you use typing. Typing is very performance costly when going to/from typed code, has to be guided so hard you practically type every expression manually (sometime with hacks like if(type is x) do-with-x(the-thing) else if(type is y) do-with-y(the-thing) else error("never happens")), can't type only some expressions in a typed file (all or nothing), yet typing can improve performance 50fold in some cases (tensors).

>chicken
No 64-bit or more datatypes.
Green threads.
>>
>>51602556
You can't beat Andrei's D, it's bigger and more powerful than you could possibly imagine
>>
>>51602456
statically typed
clean and consistent syntax that leads to highly readable and easily maintainable code
immaculate support for OOP and adequate support for other paradigms
>>
>>51602581
import javax.hook.bait;
>>
>>51602575
>I dunno man, I just guess I find null termination easier to work with.

That's because you're an unrepentant Ctard. Long before C was even a twinkle in Ritchie's benis, languages had come and gone that tested the null-terminated string and switched to length-prefix.
>>
>>51602549
tch yeah, real clever
*puts C into the rubbish receptacle*
where it belongs, heh
>>
small poll
http://bfdss.net23.net/site8/poll.html
>>
>>51602601
if you don't think
>statically typed
at the minimum is a good thing i don't know what to tell you m8
>>
kinda new to programming. is pen and paper required at any point?
>>
>>51602549
Kill yourself

>>51602530
GMP
glib
OpenCL
OpenGL
libfreetype
zlib
etc...
>>
>>51602635
Most languages are statically-typed. Why should I use Java over the many other languages with static typing, decent syntax, and multiparadigm support?
>>
>>51602637
not really except for in certain school classes maybe. but you'll probably want to sketch on algorithms and maybe designs either on the computer or on pen and paper
>>
>>51602637
I find it nice for planning shit out
>>51602581
Lots of languages have that
>>
>>51602530
just
ls /usr/lib
, most of what you'll find there will be c libraries
>>
>>51602635
>java
>clean syntax
>consistent syntax
>highly readable code
>easily maintainable code
>even remotely acceptable OOP support
>any support for non-OO paradigms whatsoever
It's bait, anon-kun.
>>
>>51602530

libcurl (networking)
libopenssl (crypto)
klib (data structures)
libsdl (multimedia)
libgtk+ (GUI)

Want more? Be more specific on what you want that library to do.
>>
>>51602530
Too many to name. Every library that isn't complete shit has a C interface.
>>
>>51602654
i don't care if you prefer some other language, it's a matter of taste i guess. but java is good for android for instance. >>51602283 is my legit opinion about java
>>
>>51602686
ok sanchez
>>
>lowercase Java shill
It's always the same guy, isn't it?
>>
File: 1448826868552.gif (3 MB, 260x209) Image search: [Google]
1448826868552.gif
3 MB, 260x209
Reminder that if you can't swap two ints in one line of code you're not even in the level of a street shitting code monkey
>>
>>51602495

I am, I've been trying to implement double linked ordered list functionality but there's way too much error in my code

Would it be possible to make a placeholder iterator? Like instead of the Node? Right now I'm trying create an insert function that inserts an item into the list based on a comparison functor (a<b) and uses iterator traversal. But obviously I can't access the direct value of the node through the iterator using the -> operator.

// Inserts an item based on the standard functors, and returns an iterator position
template <class Item, class Order>
typename DLinkedOrderedList<Item, Order>::Iterator DLinkedOrderedList<Item, Order>::insert(Item item) {
DLinkedOrderedList<Item, Order>::Iterator k; // Creating an iterator k for the linked list
Node *temp; // Placeholder node

for (k = this.begin(); k != this.end(); ++k) { // Forward iterator traversal
if (IsLess::compare(item, k->value)) { // Compares the input item with the value (item) at the iterator
temp = k; // Temp holds the contents of the node
k->value = item; // Item is assigned the be held in position k
k->next = temp; // Next value holds the previous value
m_size++; // Increments the size of the list
return k; // Returns the iterator k that the item was inserted at
break; // Breaks the "if" loop
}
else
return Iterator(NULL); // An iterator must be returned
}
}
>>
>>51602735
>anti-java memers
there is nothing wrong with java it's literally one of the best general purpose programming languages in existence
>>
>>51602671
>>51602678
alright, I was hoping I could get all comfy on the sofa, but I guess I'll move to a table
>>
>>51602125
Go
>if err != nil {
...
>}
even then, you can save a line by using
> if something, err := blah(); err != nil {
that's it.
>>
>>51602743
a, b = b, a
>>
>>51601187

trying to make an opencv web interface using angularJS, except i have no clue what im doing and i'm learning as i go.

Once I figure out how to inject html contents into a page (currently selecting 1 image processing option from the drop down just opens an entire new window) I'll have covered all the small problems.

The big one is how the hell am I supposed to let a user control an already running executable? This one I am truly stumped on and I haven't trudged through enough crap about web dev to know how to fix this.

example of what i'm talking about

http://docs.opencv.org/2.4/_images/Adding_Trackbars_Tutorial_Result_1.jpg

I want the user to be able to see updates to the final image as they change the values on the track bar.
>>
File: into the trash i go.png (688 KB, 519x680) Image search: [Google]
into the trash i go.png
688 KB, 519x680
>>51602775
>Python
Only real languages allowed, kiddo.
>>
>>51602743
>mutable variables
>>
>>51602692
Having a C interface doesn't make something a "C Library"!
>>
>>51602790
that's Go
>>
>>51602653
>can't count
>uses non-standard 3rd party libraries
why live
>>
>>51602791
>assignment == mutation
Typical of an ignorant FP autist who will never accomplish anything worthwhile.

>>51602814
Even worse.
>>
It has eh editor now!
>>
>>51602743
void swap(ref int a, ref int b)
{
int temp;
a = (tmp = b, b = a, tmp);
}
>>
>>51602821
If it's not doing any mutation, then what's the point? Just swap any occurences of "a" and "b" afterwards
>>
>>51602821
>Even worse.
>>>/a/
>>
>>51602749
store the elements in a tuple and create an iterator over it

std::get<n+1>(tuple)
std::get<n>(tuple)
std::get<n-1>(tuple)
>>
>>51602825
>one line of code
No temp variables allowed either. Also what is that meme lang, D?

>>51602844
>>>/trash/
>>
>>51602812
You should define what a C library even is. Is something a "python library" if it's usable in python but not written in it?
>>
>>51602859
>>>>/trash/
yeah, sorry, I should have told you to go there instead.

reminder: Go >> your shit language, you should learn Go before it's too late
>>
>>51602743
a ^= b; b ^= a; a ^= b;
>>
>>51602859
All the swapping was done on one line like you said and you didn't say no temp variables. I put it in a function just out of habit, I easily could have just stuck it in main.
>>
>>51602905
Lemme fix that.
a ^= b ^= a ^= b;
>>
>>51602790
It's Lua
>>
>>51602904
>Go >> your shit language
What kind of meme language uses bit shifts to denote inequality?
>>
>>51602913
nice one. this can be done in based java of course.
>>
I read up on haskell syntax, typeclasses and shit, but i CANT think in the functional way. what do i do?
>>
>>51602859
auto ref invokeSwapped(alias FN, X, Y)(auto ref X x, auto ref Y y) 
if (is(typeof(FN(y,x))))
{
return FN(y,x);
}


auto take = (int a, int b) => a - b;
invokeSwapped!take(5, 4);


-1
>>
>>51602940
Have you perchance read The D Programming Language?
>>
>>51602938
Just start using it. It'll come to you.
>>
>>51602933
uhm, have you ever heard of this thing called math (or "maths")? it's the "much greater than" sign
>>
>>51602963
>buying proprietary softbacks
>>
>>51602743
(set! a (set! b a))
>>
>>51602981
>being british
>>
>>51602981
>not writing softbacks on some obscure language and shilling them on /g/
>>
>>51602997
>being a literal tripfag
>>
>>51602822
what the hell am i looking at?
>>
>>51602814
>>51602821
whats wrong with go?
>>
>>51602997
>Being a burgerclap
>>
>>51602905
>>51602913
>bit manipulation
M E M E
E M E M
M E M E
E M E M

>>51602976
In math, = is the equals sign too. Do you also write
if (a = b)
?
>>
>>51602997
>being an anarcho-capitalist-statist-christian-libertarian
>being an attention whore
>>
>>51602991
>L*sp
Again, >>>/trash/
>>
>>51603046
*jewish
>>
>>51603042
>In math, = is the equals sign too. Do you also write if (a = b)?
are you retarded or just pretending?
>>
>>51602015
The whole thing boils down to some bumfuck saying his doesn't like the API design. That's not "broken as fuck" sorry to disappoint your undirected rage.

If you have anything concrete feel free
>>
>>51603042
>imperative assignment in math
>imperative comparison in math
haskell safe space when
>>
>>51603042
>doesn't know XOR
>calls himself a programmer
>>
>>51603081
Did you even read the article? Do you even know what an API is?
>>
Man, pattern matching in a where block is fucking me up. Why is '=' weird in Haskell?
>>
>>51603108
>cannot be implemented in a feedforward neural net
literally euphoric
>>
>>51603081
1/10 if trolling, -10/10 if retarded.
>>
>>51603124
Post your code.
>>
>>51603028
>>51603010

These things are infinitely better than living on a rock where it always rains and everyone is inbred.

>>51603046

God bless, ya'll.
>>
>>51603158
>fresh air
>anti-racemixing
>bad things
>>
>>51603051
>implying your shitty language can compete with lisp
nice one fag, why don't you show your own code?
>>
The best thing about Java is that every program is basically open source since it can be decompiled so easily.
>>
>>51603148
From lyah :

 
initials::String->String->String

initialsfirstnamelastname=[f]++"."++[l]++"."
where(f:_)=firstname
(l:_)=lastname
>>
>>51603127
>AI
nice meme

>>51603265
Do you have something against spaces?
>>
>>51603278
whitespace and comments slow down compilation
>>
>>51603127
>he doesn't know about NTM models
>he doesn't know that virtually any nonlinear net can model xor
>>
>>51603265
Christ, use spaces please.

The problem is that Haskell has significant indentation. So you need to write it like:
where (f : _) = firstname
(l : _) = lastname

or
where
(f : _) = firstname
(l : _) = lastname

or something like that.

Also, your code looks broken to fuck anyways.
>>
>>51603293
Am I being rused?

Also, [f]++"."++[l]++"." is equivalent to [f, '.', l, '.']
>>
File: Screenshot_2015-11-30-03-33-53.png (200 KB, 720x1280) Image search: [Google]
Screenshot_2015-11-30-03-33-53.png
200 KB, 720x1280
>>51603302
>>51603278
>>
Anyone have a recommendation for good books on Computational Geometry?
>>
>>51603351
Such a shit book
>>
>>51603351
I feel like this is why people say not to use LYAH. It's a pretty convoluted example where use of the "head" function and list syntax like >>51603306 pointed out are much better.

My point about significant indentation still stands, see how it's written in the book?
>>
>>51603110
Not seeing anything concrete out of you, just a bunch of whiny bitch tears.
>>
>>51603355
heh yeah
*unzips cargo shorts*
compute this
>>
>>51603144
> Nuh uh
> Because it is
> Actually say something of substance? How do I do that?
>>
>>51603265
Don't be a nigger.
 
initials :: String -> String -> String
initials firstname lastname = [head firstname, '.', head lastname, '.']
>>
File: GOTEEM.png (6 KB, 700x34) Image search: [Google]
GOTEEM.png
6 KB, 700x34
>>51603042
>In math, = is the equals sign too. Do you also write
if (a = b)
?
>>
/** Small Straight: four of the five dice have consecutive values( e.g. 2,3,4,5 */
public static boolean isSmallStraight( int [] rolls ){

int consecutive = 0;
int counter = rolls[0];
for( int i=0; i<rolls.length; i++ ){
if( rolls[i] == counter )
consecutive++;
else
counter--;
counter++;
}
return consecutive == 4;
}


Can anyone top this?
>>
>>51602971
This desu. There was one book I wanted to read which contained OCaml code. I was rubbish at the start but I got it by the end.
>>
File: smug clockmed.png (109 KB, 269x228) Image search: [Google]
smug clockmed.png
109 KB, 269x228
>>51603265
>initialsfirstnamelastname
>>
>>51603435
-10//10 it is then.
>>
>>51603532
Nothing to say it is then.

Whats the matter? Too much of a bitch to say something for fear you might show your ignorance? It certainly seems so.

Or you could just respond with some internet meme insult like a child.
>>
>>51603503
I, uh...
>>
Java
>>
Java
>>
>>51602125
C#
can only use => to define read-only properties.
Should be able to do
public type PropertyName => member.ReadWritePropertyOfSameType;

and have the derived property be read/write.
>>
can you generate files on server using html
>>
>>51603503
It's shit.
/* Get number of consecutive rolls. */
size_t
getnconsec(const int *rolls, size_t nrolls) {
int nconsec = 0;
for (size_t i = 0; i < nrolls - 1; ++i)
if (rolls[i] + 1 == rolls[i + 1])
++nconsec;
return nconsec;
}

bool
is_smallstraight(const int *rolls, size_t nrolls) {
return getnconsec(rolls, nrolls) == 4;
}
>>
First for go
>>
>>51603784
>rolls[i] + 1 == rolls[i + 1]
++*rolls == *++rolls
>>
>>51603847
>const int *
>>
>>51603847
Undefined behaviour, you fuckwit.
>>
>>51603847
Those don't do the same thing
>>
Can I create a loop in a new function?
>>
>>51603908
Yes, unless you're using a language that doesn't have loops.
>>
>>51603503
I'm not even sure if your code is correct to begin with...
>>
>>51603908
Why don't you fucking try it out??
Nobody's gonna stop you, and it won't hurt that much if it doesn't work.
>>
>>51603759
use Java
>>
>>51603943
In some languages, it's very impractical to "just try out" something. For instance, opendylan (by contrast with mindy) requires a project and lib file accompany any source file that is to be compiled and they must all have the correct information so the project can be compiled.
>>
>>51603940
>>51603784
I fixed it
/** Small Straight: four of the five dice have consecutive values( e.g. 2,3,4,5 */
public static boolean isSmallStraight( int [] rolls ){

int consecutive = 0;
int counter = rolls[0];
for( int i=0; i<rolls.length; i++ ){
if( rolls[i] == counter )
consecutive++;
else
counter = rolls[i];
counter++;
}
return consecutive == 4;
}
>>
The D programming language has a function called
makeTrans
>>
>>51604022
It's still just searching for a sequence of identical values, isn't it?
>>
>>51604165
:^)
>>
>>51604022
Still horrible. It's not idiomatic at all (at least I hope that's not a Java idiom).
>>
>>51603784
I don't think this works with duplicate values say {1,2,3,3,4}
>>
tfw I was doing while loops and copy/pasting previous work, and as I was working with a different program, I found out that I could have just done a do loop.
>>
>>51603984
If you're using such a heavyweight language, you wouldn't be asking trivial questions like that.
Still, that sounds like a pain in the ass for any scale of development.
>>
>>51604215
Visually there appears to be 3 consecutives in that list. Without changing the logic, my function returns 3 on that list. Unless you're saying getnconsec({1, 2, 3, 4, 5}) should evaluate to 5 I don't know what you mean.
>>
>>51604210
k bud its not that bad alright
>>
>C++ doesn't have ranges
>C++ doesn't have uniform function call syntax

Why live?
>>
>>51601270
It really depends on your own diction of the topic.

If you deal in high level arguments, words such as do and go come to mind, then you can write one huge function of write several sub functions to act as breakpoints in your code. If you deal in low level arguments, you can literally divvy up tasks in a procedural manner ( or go the almighty haskell route of functorial ) and encapsulate the events via a class system or use structs to designate the appropriate structure to be worked on so that you can do it all at any time you see fit but also manage to keep the data from eventually colliding.

Best tip, from me to you, is to figure out what parts you might want to change and put that in a separate function. If there is some work in a few line passes that you cannot omit, create a lambda function and do the work there and then return to the normal sequence of the function.

This code is ultimately for you. Only you can dictate the pace, really.
>>
>>51604316

Learn from that
>>
>>51604464
Are you trying to sound complicated?
>>
>>51604394
If you're using such a heavyweight language you're in the only position where you should ask these questions actually.
And yes, it's a pain in the ass for small projects, but for medium or large ones, you'd be providing a library and project file with your source anyway so it doesn't change much.
>>
>>51604455
C++11 has ranges I think. What's a uniform function call syntax?
>>
>>51604567
I think ranges were proposed for C++14 but set back to C++17
>>
>>51601538
>>51601625
max_sum = max(sum(i) for i in lists)
>>
>>51604567
C++11 has range-based for loop, but not ranges (which are in a sense a generalization of iterators).
>>
Whats everyones favorite pl t ciclejerk. I currently know python, c++, racket, and a bit of java.
I found racket to be stupid at first but looking back functional languages are pretty cool. Should I learn Haskell. Im going to be start working on some things and was wondering if I should just stick to c++ or if Haskell was the superior language that everyone circlejerks.
>>
>>51604626
I think there is, with Iota<x>, as in
for(unsigned i : iota<10>) {
...
}
>>
>>51604629
OCaml is the industry-approved version of haskell. It's also less gay with indentation and has support for mutability and OOP.
You should go back to racket first, though, since you seem to finally be open to accept scheme's greatness.
>>
Dong work for a book to learn c++. Made this program after the chapter on vectors while/for loops and create your own functions.
#include "std_lib_facilities.h"

int main() {

vector<string> words;
vector<string> disliked = {"broccoli", "beans", "spinich"};

for(string temp; cin>>temp;)
words.push_back(temp);
cout << "Number of words: " << words.size() << "\n";

sort(words);
vector<string> print_list;

for (int i=0; i<words.size(); ++i) {
if (i==0 || words[i-1]!=words[i]) {
for (int j=0; j<disliked.size(); ++j) {
if(words[i]==disliked[j]) {
print_list.push_back("BLEEP");
break;
}
if (j==(disliked.size()-1)) {
print_list.push_back(words[i]);
}
}
}
}

for (int k=0; k<print_list.size(); ++k){
cout << print_list[k] << "\n";
}

return 0;
}


It works but I want to break it up into functions because I have a hard time fucking with it while keeping it all straight.

Occurred to me I do not know what a function looks like when I want it to return a vector. Anyone know how to do that? I know you can send one a vector with just the name like sort().
>>
>>51604567
C++11 doesn't have ranges, it has a range-based loop.

Uniform function call syntax:
x.fn(a, b, c) (where x has no member fn)
->
fn(x, a, b, c)
>>
>>51604675
Huh, never knew that we had that. Perhaps it is _a_range_ but it is hard to express more of them in current C++?
>>
>>51604692
How's multicore in OCaml these days?
>>
>>51604728
inb4 use templates to make a monad to do this for you
>>
>>51604748
Not him, but according to what I've heard it still doesn't exist. I don't personally use it though so I am not the biggest expert.
>>
>>51604728
>I can't read: the post
>>
>>51604728
uniform function call syntax is not always beneficial.
C++ gains features for not having that. The grass isn't always greener, and just because you have an opinion doesn't mean it's correct.

As for ranges, I can implement a fully generic lazy range in ~50 LOC. Unless you're talking about something else and you just don't want to tell us what it is?

I disagree with lots of things about C++ but ranges and uniform function calls are the very least of its issues.
>>
>>51604817
>uniform function call syntax is not always beneficial.
>C++ gains features for not having that.
Er...what?
>>
>>51604748
4.03 supports multicore, and there's a compiler hack that enables it anyway.
Coincidentally, I was impressed to learn how many languages didn't have any multicore support.
>>
>>51604841
virtual functions.
Less possibility for ambiguity in C++'s already confusing overloading semantics.
>>
I honestly never pay attention to C++ code and have never really had an interest in learning. I mostly write C and Python but I'm interested in looking at C++ a little.

What's the K&R of C++?
>>
>>51604841
The ability not to have _____the___self_object___of___selfness___.param
everywhere in function bodies.
>>
>>51604800
I don't understand what you mean.

>>51604817
Ranges + UFCS + algorithms are a really good combination, but I could understand not wanting them.

TBQHF I think UFCS should be a standard library monad.
>>
>>51604875

One of the Stroustrup books. Programming: Principles and Practice Using C++ second edition is kinda a learner book.

The C++ Programming Language 4th edition is more a manual for people that are completely comfortable with programming already.
>>
>>51604860
Yeah I think I remember Erlang only fairly recently (in the grand scheme of things) getting proper multicore support.
>>
>>51604912
I recently wrote a programming language that depends on methods rather than UFCS, because type overloading is impossible due to type inference.
4.equal(5) // -> false
4.equal(4) // -> true


However, I added syntax that mimics UFCS in some respects
let f = .equal :: int; // f : fn(int, int) -> bool
f(4, 5) // -> false
f(4, 4) // -> true

It even works with type inference (sometimes)
fn foo (f : fn(int, int) -> bool) {
f(4, 5)
}
...
foo(.equal) // -> false
Thread replies: 255
Thread images: 15

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.