[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: 355
Thread images: 23

File: comfy.png (82KB, 1183x628px) Image search: [Google]
comfy.png
82KB, 1183x628px
Previous Thread: >>55602501

What are you working on, /g/?
>>
getting high and masturbating to traps
>>
Considered doing

instance (Listable a) => Eq (a -> b) ...
>>
>>55610068
and
(Listable a, Listable b) => Listable (a -> b)
>>
>>55610026

That file name is misleading.. This is nothing like the "Comfy programming language"
>>
RATE MY PERMUTATION GENERATOR LADS

public class Test 
{
public static String remove(String a, int index) {
return a.substring(0, index) + a.substring(index+1);
}

public static List<String> getPermutations(String base) {
ArrayList<String> myList = new ArrayList<String>();
if(base.length() == 1) {
myList.add(base);
return myList;
} else {
for(int i = 0; i < base.length(); i++) {
char ch = base.charAt(i);
String st = remove(base, i);
List<String> stl = getPermutations(st);
for(String s : stl) {
myList.add(ch + s);
}
}
return myList;
}
}

public static void main( String[] args )
{
String test = "abc";
System.out.println(getPermutations(test));
}
}
>>
>>55610131
There's a permutation generator in the OP:

[] : [ h : v | v <- values, h <- values ]

some type inferring type class wizardry going on there
>>
>>55610141
Not actually a permutation generator, whoops
Generates all possible lists, so you'd have to filter the length to get all the permutations

values = [] : [ h : v | v <- values, h <- values ]

It was partly thought about, partly looked up and partly guesswork, but I really like the answer
>>
>>55610141
>[] : [ h : v | v <- values, h <- values ]

Someone explain this israelite magic to me
>>
>>55610163
Not a permutation generator, it's a generator for every possible value a list could have

Do you understand list comprehensions?
>>
>>55610174
I don't know the slightest bit about haskell, but I know a little about python's list comprehensions. Are they similar?

>a generator for every possible value a list could have
How is this possible? Aren't there infinitely many possibilities?
>>
>>55610190
It is similar

>infinite
yes, it's infinite, that's why my example uses "take 14" to only take the first 14 elements of the list
this is due to lazy evaluation & recursion
lazy data structures are magic


x:xs is a list [x] ++ xs (where xs is a list)
So the first thing you see is

[] : [...]
The empty list is one of the possible values of "all lists". It's followed by all the other values.

[ h : v | v <- values, h <- values ]
The v is where it recurs.
For every v in values (which we are defining right now), and then for every h in values#a (possible values the element type can have) we have the previous list with our new element appended
>>
>>55610218
Type inference allows it to infer which instance of "values" to use (was quite magical when it all worked out)

Similar for the Either a b and (a,b) examples, where it knows to use values#a and values#b
>>
File: logo.png (8KB, 227x95px) Image search: [Google]
logo.png
8KB, 227x95px
I've been learning pic related. Any suggestions for some cool projects to work on?
>>
>>55610218
So for a run through:

[] is our first part of the list of (lists of a)

Then for all the items in this list (we start with [])
for every a: a0 a1 ... an
a0:[], a1:[],... an:[]
(all one-item lists of a's)

Now we've got some new values in our meta-list to start from

a0:[a0], a0:[a1],... a1:[an]
a1:[a0], a1:[a1],... an:[an]
...
an:[a0], an:[a1],...an:[an]

All two-element lists.
etc.
>>
>>55610265

A private server for some random game.
>>
>>55610026
/dpt/+/csg/ thread when?
>>
>>55610026
Could someone with a reddit account or 4chan gold post the OP pic to r/haskell and ask for suggestions or additions?

Bottom/undefined not being an element is intentional
Requires a few ghc language extensions
>>
>>55610386
Feel free to discuss computer science in /dpt/
/sci/ aren't fond of computer science from what I've seen
>>
File: 1396576769733.png (571KB, 497x481px) Image search: [Google]
1396576769733.png
571KB, 497x481px
>>55610044
me too anon lets do it together
>>
>all these functional languages popping up are just some managed byte-code interpreted virtual machine bullshit like java and C#

i thought something that looked so low-level was gonna at least emit assembly code
>>
>>55610110
>muh blub
>>
>>55610407
>Feel free to discuss computer science in /dpt/
>/sci/ aren't fond of computer science from what I've seen
>>>/g/csg
>>
>typical functional code
[}{}[]---}{]{[][]{}{]]{]foo}{])---|||||||Bar----<<:::::::: |():
>>
I'm trying to learn how to program, I choose clojure because the code seems clean. The problem is that there isn't much documentation for first timers. I reached a point that I literally don't know what to study. Whatever I try to do end up on failure and even on simple problems I have to find a solution on the web.

Should I change the language for something more simple? I'm learning just because. I don't have any real intention on making a career or anything.
>>
>>55610577
Pick to a language that isn't based on being a Lisp ((car)(cdr))((mess)
>>
>>55610577
Pickup C, I learned to program with that lang (even though I used two before).
Try the book: "C programming a modern approach".
>>
>>55610577
Read SICP. It's full of interesting problems that clojure can probably be used for.

>>55610590
kys
>>
File: 0%2FoaFq.gif (528KB, 756x400px) Image search: [Google]
0%2FoaFq.gif
528KB, 756x400px
trying to do some simd speedups for my after effects plugin
>>
>>55610597
The problem is that when I see the code for language like C I feel like there is too much synthax and that is a boner killer to me, I don't know why... Maybe that is not case of C, I'm not really familiar with all the popular languages desu...
>>
>>55610629

Vector fields?
>>
>>55610577

If you're dead set on starting with functional programming Schala might be a better choice.

Otherwise look into C, C++, or Rust. The first two have vast amounts of learning resources.
>>
File: diag.gif (2MB, 759x522px) Image search: [Google]
diag.gif
2MB, 759x522px
>>55610639
yep
http://www8.cs.umu.se/kurser/TDBD13/VT00/extra/p263-cabral.pdf
http://www.impa.br/opencms/pt/ensino/downloads/dissertacoes_de_mestrado/dissertacoes_2009/Ricardo_david_castaneda_marin.pdf
>>
>>55610632
You're 100% correct. C is full of bit-diddling minutiae and warts galore. Programming a computer and learning computer science are too very different things. Stick to Lisp-like languages for learning the actual abstractions, then worry about the mechanical shit later.
>>
>>55610632
No man, you're wrong, C is pretty tidy, there's just a little bunch of keywords to learn.
Of course, to make something big it will need a lot of Lines of Code, but I think you can move to another language after grasping the programming concepts.
>>
>>55610648
Scala is an awful choice desu
>>
>>55610632
There really isn't very much syntax at all.
All you need to learn is basic arithmetic, pointers, labels&goto
>>
>>55610628
>>55610632
>>55610648
>>55610660
>>55610664
Programming is not about languages.
>>
>>55610700

This is what someone who masters a shit language says
>>
File: 2016-07-17-055339_754x633_scrot.png (176KB, 754x633px) Image search: [Google]
2016-07-17-055339_754x633_scrot.png
176KB, 754x633px
Is this True?
>>
>>55610675

It's a transitional language from functional techniques to oop / commonly used languages.

>>55610700

This is true. However, languages do leave their mark on the programmer. You pickup various techniques and thought patterns for solving problems from each language.
>>
>>55610748
Read his post again. He's learning a language for the first time. He doesn't need to "transition." He should stick with Lisp syntax because it is unambiguous, out-of-the-way, and allows you to focus on learning what really matters.

If there's not enough documentation for Clojure, switch to Scheme or CL then.
>>
>>55610748
>This is true.
No it isn't. The same two or three faggots restate it every thread.
All languages are not the fucking same.
A language can be objectively worse.

>oh you cant actually prove anything
You're all subjectivist hipster faggots
>>
>>55610771
yeah let's not give the kid autism jump start, should start with javascript instead actually
>>
>>55610731
This is true.
Regex is context free. For example, you can't write a regex where there's an equal number of 0s and 1s.
It's similarly difficult for opening and closing tags in xml
>>
File: 1467489013747.jpg (36KB, 704x528px) Image search: [Google]
1467489013747.jpg
36KB, 704x528px
>>55610802
>context free
>tfw no comonads
>>
>>55610775

Programming is about solving problems or creating simulations.

The language is just a tool to express techniques. Some tools are made to be strong with certain styles of problem solving. Picking up a new tool exposes the programmer to new techniques .

Programming isn't about the languages as much as it is about describing and solving problems. This logical process is language agnostic. Some languages just make certain methods of problem solving extremely hard or impossible to implement.
>>
>>55610131
Why don't you write some real program instead of just practicing?
>>
>>55610802
You mean regular languages form a strict subset of context free languages. A language where words contain the same number of 0s and 1s is outside that subset.

Althought the regexes used in PCRE, Python, etc. accept a larger set of languages than textbook regular expressions, by means of backtracking, but that just leads to a mess.
>>
>>55610771
SICP is about specific languages, not programming.

I never think in the syntax of a specific language when I program, even when I use those languages. Lisp syntax has to do with simplifying parsing for a machine. C syntax is based on the personal preferences of its designers.
>>
is it worth to read SICP for someone that already knows the basics of many languages?
>>
why do I feel completely unconfident when programming or planning something?
I'm a college dropout. I don't practise much, and when I try writing something, I feel like shit. it's like I kind of fear doing things. plus, learning something in a "formal" way, requires a lot of time, while "just doing" things leaves me thinking that I don't know shit. so I end up doing nothing
>>
>>55611016

He wouldn't have if (you) hadn't given him one.
>>
https://code.world/blocks
Interesting visual language
>>
>>55611160
i think you should get some therapy to help you with confidence issues

you are unwilling to do things in the so called "formal" (as you put it) way because you are scared that you wont be able to pick it up. Your "thinking that i dont know shit" comes from an internal fear, the fear that you didnt immediately pick up the skill. Stuff takes work to learn kid, and it's not even hard, just time consuming
>>
I have literally no idea why I did this..

template<typename ret, typename function>
std::vector<ret> Map(std::vector<ret> data, function& lambda)
{
std::vector<ret> Result;
for (auto i : data) {
Result.push_back(lambda(i));
}

return Result;
}

template<typename ret, typename function>
std::vector<ret> Filter(std::vector<ret> data, function& lambda)
{
std::vector<ret> Result;
for (auto i : data) {
if (lambda(i)) {
Result.push_back(i);
}
}
return Result;
}

template<typename ret, typename function>
ret Reduce(std::vector<ret> data, function& lambda, ret InitValue)
{
ret Result = InitValue;

for (auto i : data) {
Result = lambda(Result, i);
}

return Result;
}
int main()
{
std::vector<int> Test = { 8, 4, 6, 10 };
auto Lambda = [](int x) { return x * 2; };
auto Test_Filter = [](int x) { return ((x % 4)) ? false : true; };
auto Test_Reduce = [](int x, int y) { return x + y; };

auto Result = Map(Test, Lambda);
auto Result_Filtered = Filter(Result, Test_Filter);
std::cout << "Filter Result 1: " << Test_Filter(Test[1]) << std::endl;
std::cout << "Data: ";
for (auto i : Test) {
std::cout << i << ", ";
}
std::cout << std::endl << "Result: ";

for (auto i : Result) {
std::cout << i << ", ";
}
std::cout << std::endl << "Filtered Result: ";

for (auto i : Result_Filtered) {
std::cout << i << ", ";
}
std::cout << std::endl << "Reduced Result: " << Reduce(Result, Test_Reduce, 0);
std::cin.get();
}
>>
>>55611465
>not Result(data.size())

SUB OPTIMAL
>>
The sad thing is people actually thing functional programming is just "map filter reduce"
>>
>>55611478

It'll work for map. However, in a lot of cases Filter will allocate extra data with that method. I could take a third parameter for initial vector size.
>>
>>55611505
Yes, but it's often better to over-allocate and shrink than under-allocate and grow
>>
Have any of you ever written a text editor? I wanna write one in Python, but I have no clue where to start.
>>
imperativefags are on full shitpost mode today

probably just jealous of the beauty of functional
>>
File: runtime get out.png (22KB, 1161x407px) Image search: [Google]
runtime get out.png
22KB, 1161x407px
>>55611530
>>
Trying to practice techniques from Robert Martin's Clean Code book, could this function be further refactored?

void OnCollisionEnter(Collision collision)
{
Quaternion currentFlipperRotation = flipper.transform.rotation; //get current Rotation value of flipper to compare with start/end value
if (Input.GetButton(buttonName) && currentFlipperRotation != flipperStartPosition && currentFlipperRotation != flipperEndPosition) //if flipper button is being pressed and flipper is not at rest or full extension...
{
collision.rigidbody.AddForceAtPosition(flipperForceDirection.normalized * flipperForce, flipperOffset.transform.position); //...then hit it!
}
}
>>
>>55611530
Tbh I wish Haksell had some kind of C++-esque syntax for imperative coding.

Also using monads and not using structural effects and co-effects is kinda lame.
You end up with all this bullshit that's all isomorphic like IO State and State IO and requires a million wrappers
>>
>>55611497

A lot of problems can be solved in a functional manner with just "map filter reduce bind"
>>
>>55611579
There are do blocks for monads. Most imperative coding would violate the purity haskell holds so precious.
>>
>>55611581
There's a great deal more to it than just list comprehensions

Though a lot of those are a lot more general than lists
Map - any functor
Bind - any monad
Reduce - any foldable
Filter - any foldable monadplus
>>
>>55610731
It's true in theory. But in practice it's possible. The second highest voted answer goes into more detail.
>>
Is there any functional language that emits assembly code or is it all managed byte-code bullshit
>>
>>55611614
No, you've missed the point
do x <- get
put x + 2
return x

vs
imperative | x += 2 ]


Plus structural effects are much nicer in a type system than monads

>>55611626
Some transcompile to C and C++ rather than bothering with assembly
>>
>>55611626
I think the spirit of your question is "are any functional languages faster than C?" The answer is "nah".
>>
>>55611626
Haskell is compiled to machine code.
>>
>>55611636
lens I think has a += operator, that behaves roughly like imperative +=. You could also define a += for numerical IORefs if you wanted to
>>
>>55611636
Also Oleg's extensible effect system has structural effects (which is of course represented as a monad)
>>
>>55611712
The point being that imperative syntax is usually better for imperative programming
>>
>>55611636
I don't entirely follow. What is the += operator supposed to accomplish?
>>
so I have glm in my library

it uses the MIT license which wants a copyright notice. but it doesnt specify if its for binary redistribution.
every result i see is vague as to if I should and the notice is just

"Copyright (c) 2005 - 2016 G-Truc Creation"

should i make it
"OpenGL Mathematics (GLM) Copyright (c) 2005 - 2016 G-Truc Creation"
>>
>>55611731
You can use += in a do block and it will look like an increment statement
>>
>>55611735
You can do `x += 2` instead of `x = x + 2` like you would in BASIC
>>
>>55611749
If this is too much of a pain you could opt for datenwolf's linmath.h like I do (it's WTFPL, effectively public domain), although I use it because it works in C and glm doesn't

>CAPTCHA says 420
>>
>>55611722
(extensible effects): http://okmij.org/ftp/Haskell/extensible/
>>
I want to start programming. What language should I start with or what books should I read?
>>
>>55611735
It is an example of imperative synatx for the other

>>55611792
Haskell
>>
>>55611792
INTERCAL
>>
>>55611756
what's wrong with
let x_ = x + 2
>>
>>55611802
Doesn't even do the same thing, is needlessly repetitive, etc
>>
>>55611792
What types of things do you want to program?
>>
>>55611824
No idea. I mostly just want to learn for the sake of learning.
>>
>>55611807
Is the only point to change the value referred to by x? What purpose does that solve that using a different variable name wouldn't?
>>
File: snow spiral smooth.webm (892KB, 960x640px) Image search: [Google]
snow spiral smooth.webm
892KB, 960x640px
>>55610657
>>
>>55611852
It is a stateful computation that increments x by 2 and returns x
>>
>>55611792
I started out with QBASIC and some old BASIC books from the 80s despite growing up in the 90s, the upside was you could screw around with graphics, the downside is BASIC is a rather clunky language

I'd almost suggest C but I don't know of any good tutorials at this stage, so right now I'll suggest Python, and use the "Think Python" book ("Python The Hard Way" can eat shit... apparently "C The Hard Way" is decent though)

As an added bonus, learning Python typically means you learn to indent your code

>>55611802
I've done Erlang before, you do end up with some horrible shit like

X2 = X + Foo,
X3 = X2 + Bar,
X4 = X3 + Baz,
{X4, "Should've gone to SpecSavers"}.


Slightly unrealistic example, but a fairly realistic extent of roughly how far you tend to go out when spewing out new names
>>
(+=) :: Num a => IORef a -> a -> IO ()
var += x = modifyIORef var (+ x)

meme :: IO ()
meme = do
x <- newIORef 0
x += 5
x += 7
print =<< readIORef x


λ> meme
12
>>
How can I improve my algorithmic coding? I've been into high level OOP design for a while, but when trying to implement algorithms, even simple ones on code challenge sites, I find myself sitting there for 30 minutes or so.

In a technical interview for a job I think I'd struggle. How can I improve this skill?
>>
>>55611830
Python is the go-to beginner's language. Simple, flexible, widely used with many libraries, good introduction to most concepts in programming. My main complaint with it is that I find it boring to write.
>>
>>55611867
forgot
import Data.IORef
>>
>>55611867
basically this
>>
>>55611867
also forgot I put a type annotation on 0

import Data.IORef

(+=) :: Num a => IORef a -> a -> IO ()
var += x = modifyIORef var (+ x)

meme :: IO ()
meme = do
x <- newIORef (0 :: Int)
x += 5
x += 7
print =<< readIORef x
>>
>>55611287

I see if and else, but not define function or call function, or any means of looping, or jumping to a label. Not turing complete?
>>
>>55611577
I decided it could be, and moved the check from the if statement into a new boolean function. I also changed some variable names. How's it look? (C# in Unity btw)

void OnCollisionEnter(Collision otherObjectInCollision)
{
Quaternion currentFlipperRotation = flipper.transform.rotation;
if (FlipperIsNotAtRest(currentFlipperRotation))
{
otherObjectInCollision.rigidbody.AddForceAtPosition(flipperForceDirection.normalized * flipperForce, flipperOffset.transform.position); //...then hit it!
}
}

bool FlipperIsNotAtRest(Quaternion currentFlipperRotation)
{
return (Input.GetButton(buttonName) && currentFlipperRotation != flipperStartPosition && currentFlipperRotation != flipperEndPosition);
}
>>
>>55611911
Dunno, I don't see any either, I just meant it was interesting

luna lang is in alpha but that looks far more interesting - full dependent typing, structural effect system, etc
>>
>>55611911
neither are physical computers
>>
>>55611621

At it's core pure functional programming is just guaranteed results that are calculated based on the input arguments without side effects.

Don't confuse Haskell's methodologies and techniques with core functional style programming.
>>
>>55611933
Functional programming isn't just that, it's also first order functions + an expectation of currying, among other things.

Type and category theory are strongly related
>>
I'm trying to grasp the concept of hashing, but I don't see how it's better than just storing values. Any resources?

Also, is python dictionaries equivalent to hashing?
>>
>>55611933
Basically "map/reduce/filter" is said by languages that want to pretend to be functional while having very little decent support
>>
>>55611947
yes
they are both regarded as meme math by real mathematicians
>>
>>55611968
Why do you hate FP so much?
What did it ever do to you?
>>
>>55611975
??????
>>
>>55611873
Project Euler has a few good examples of algorithmic challenges, I'm guessing you've checked it out but if not you should.

Basically, you need to learn more maths. No more sorting types of animals that need to get off the kitchen variety of table, we're going to learn the important shit.

Here's a question, if you solve it, it should definitely help with some of the puzzles you'll encounter (e.g. FizzBuzz):

Given the positive integers x, y: x % y (% pronounced "modulo" or "remainder") gives you the remainder of what happens when dividing x by y (e.g. 5 divided by 3 essentially gives you 1 w/ remainder 2, and so 5 % 3 = 2). Using this knowledge, how can you tell if an integer 'p' is divisible by an integer 'q'?
>>
>>55611988

well with fizzbuzz, and similarly to find divisibility, you to if p % q == 0.

Not even I'm stupid enough to get fizzbuzz wrong in an interview. I'm re-learning math from the ground up since I was in the dumb classes as a kid. I did IT as my degree basically and graduated top of my class (no meme).

I don't want to be a shitter though, I want to get into real software development, but all my cs knowing friends can solve algorithmic problems faster and more efficiently than I can. It's time I started kicking their asses
>>
>>55612013
That, and a knowledge of looping + adding shit together, should get you through Project Euler problem #1.

Care to give an example of an algorithmic puzzle you're struggling with?
>>
>>55611947


Fair enough let me rephrase the statement. Core Functional programming is Lambda Calculus.
>>
>>55610509
It's okay to not understand things, but it's a sin to be retarded.
>>
>>55612064

I don't think there's anything in particular, just that I seem to struggle to come up with technical solutions, and also to read very technical code (which much of algorithms is).

Just for an example, I spent like 15-20 minutes figuring out how to do an array rotation so I could put it on hackerrank. My solution was correct for all outputs, but I had to revise it which took even longer since i failed test case 8 due to timeouts (took too long when the test case had about 70k elements and 60k rotations).

Just thinking and reasoning about this type of code is much lower level than the normal OOP stuff I'm used to which is just modelling things from the real world with simple behaviours
>>
Trying to develop my own PXE Server software. What's the right way to approach low-level network communication in Python? Currently I'm working on the BOOTP/DHCP portion just using struct and socket modules, and everything seems to be working okay for basic functionality. Any other useful stdlib modules I should know of?
>>
Developing FP was a great idea, now programmers don't even need to write useful programs to feel good about themselves.
>>
>>55612102
I'm going to choose not to evaluate this IO action
>>
Why is Prelude so messy and when will Haskell fix it?

e.g.

all the redundant specialised functions that have been generalised

predefined definitions of functor, applicative for monads
rename mappend & mempty, or just remove them entirely and use (Monoid m, Monad m)
etc

more type classes, like zippable
zipWith :: (a -> b -> c) -> t a -> t b -> t c

break up Num
>>
>>55612104
evaluation doesn't cause execution of IO actions

>>55612132
>muh backwards compat
Nothing can be both Monoid and Monad, it would be a kind mismatch
>>
>>55612143
*Monoid (m a(
>>
>monad transformer stacks
monads were a mistake
>>
GIRLSCANCODE

#LoveWins


"""""""""""""""""""""""""""""""CODE"""""""""""""""""""""""""""""""
AN EMOJI

https://www.madewithcode.com/projects/emoji
>>
>>55612096
That one's probably a bit of a bastard to get working at a good speed. If you're using C you may see some improvements by avoiding parsing the numbers but that trick is most likely not going to help you in Java. Plus they'll probably manually check it and then slap you for doing it and you won't pass it anyway.

You definitely want to parse them as integers rather than floats, as int->float conversion is still a bottleneck in some cases.

That puzzle's kinda shit in my view just because of the limitations.

You're basically doing something like this:
for y in 0...((N+0)/2) do
for x in 0...((N+1)/2) do
t = A[y][x]
A[y][x] = A[x][N-1-y]
A[x][N-1-y] = A[N-1-y][N-1-x]
A[N-1-y][N-1-x] = A[N-1-x][y]
A[N-1-x][y] = t
end
end


(Yep, pseudocode.)

A more fun puzzle is to actually allow the use of temporary buffers, and possibly even SIMD stuff. That way you can actually optimise it for a real computer instead of having the computer fight you because the cache hates you.
>>
>>55612220
I'm envisioning a parody of this where you code a sandwich
>>
I've almost solved the Collatz conjecture I just need some help with the DOES_HALT function...anyone?

def collatz(n):
while True:
if n == 1:
return
if n % 2 == 0:
n = n / 2
else:
n = 3 * n + 1

def checker(x):
i = 1
while True:
if not DOES_HALT(collatz, i):
return
i += 1

collatz_conjecture = not DOES_HALT(checker, 0)
>>
>>55610026
A shitty web app for inventory in php.
my lack of experience and patience is showing up in the messed up code combinations of html/css/php/javascrip/mysql.
Is there an optimal way/tool to develop web based apps? i spent the whole day dealing with a simple data base validation inside a form and ended up with 20 diferent javascrip/jquery/ajax funtions in the same page.

it kinda works but i dont know, it just looks so messy and unprofesional, i wont feel good getting paid for this.
>>
>>55612266
def DOES_HALT(x):
x()
return true;
>>
>>55612266

https://en.wikipedia.org/wiki/Collatz_conjecture#Undecidable_generalizations
https://en.wikipedia.org/wiki/Halting_problem
>>
>>55612338
yeah but i'm okay with a DOES_HALT that just works for this specific case, not in general :)
>>
>>55612220
Girl scan code?
Is that like barcode or QR code? Where is it?
>>
>>55612220
yo why the hate if it gets more people into computer science? we all started somewhere
>>
>>55612371
Wow, sure looks like women are already lining up to join /dpt/
>>
>>55612409
I believe you misread, I said computer science, not autism and circlejerking
>>
>>55612481
There's no circlejerking in /dpt/ because Y isn't well typed
>>
>programming
>posts pic of database

nice try $20/hour scriptmonkey
>>
what is the typical hourly wave for your job (state position too)
>>
>>55612834
neet/hr
>>
>>55610026
I'm trying to learn haskell's Brick library, but I'm having trouble.
I read some of the user guide, but its not meant to teach you from the ground up (its more like a reference guide)
Where do I start, how did you guys learn Brick
>>
>>55612371
>Computer science

you mean writing websites and smartphone apps
>>
>>55610731
the first sentences are literally the same lmao
>>
>>55611636
fmap (+2) get
>>
>>55612905
Note: I haven't actually used brick. I don't think it has so many users that you will find many in this thread, but that is probably just because not many haskellers are making interactive terminal programs with fancy drawing and input handling.

I think the reason the user guide is so bare-bones is that the brick library mainly provides just event handling and terminal drawing. You just tell it how to draw your current state, and how to change the state when an event comes in (like keypresses). Anything like frames or things your terminal app has will need to be handled using custom logic, and encoded somewhere in your application state. The user guide doesn't tell you how to design that part because it doesn't provide anything for it.

I would guess the most complicated part (API-wise) is the drawing functions. I haven't looked at that part much so I can't help there.
>>
>>55613070
honestly, I just want to know how it all works, but its impossible with obscure languages

is learning everything with Java / Python / C and then implementing in obscure langs the only option?
>>
>>55613123
How much Haskell do you know already?
>>
>>55613123
Also I lied about brick not providing application-specific things, it looks like it does contain quite a few things. For example the Dialog module lets you create a Dialog (menu with options), and has functions for rendering it and for handling events for it.
>>
>>55613153
I know up to monads, trying to learn transformers
and I aren't exactly enlightened on what monads exactly are, but I kind of understand how they work.

I've written some private useful programs, the two latest being some shitty json parser, and a 4chan image downloader (which uses that shitty json parser)
>>
if i already published like 3 apps on google play and made like 4 dollars this week on these simple yet effective apps and the ones i have available for free have like 200 or more downloads, can i call myself a developer?
>>
>>55613183
What's your "order" for haskell concepts? I learned through functors and skimmed a bit about monads for IO purposes. I'm wondering how much more there is to go.
>>
>>55613282
i learned from http://learnyouahaskell.com/
basically:
curry -> map + filtering -> folding -> function composition -> functors -> applicatives -> monoids -> monads
and then I went to the haskell wiki, which teaches you more stuff like monad transformers and other syntax
>>
>>55611530
Why not both?
There are some things in Haskell where I'd wish I had something more imperative. Rust is the perfect combination IMO. Variables are immutable by standard, map and folds available, traits (which are the same thing as typeclasses), static type system and as fast if not faster than C++.
>>
>>55613282
also, theres more advanced shit like lenses and generic learning of necessary libraries such as parsec, which should take a while

what I want to know is, how the fuck do people learn librarires?
do they read the actual code of the library, or do they read blog posts about it?
>>
I am thinking about writing a virtual machine for http://moxielogic.org/

Pretty neat RISC architecture, GCC availible... what do ya think /dpt/s?
>>
>>55613339
srs?
I thought rust was a systems lang, therefore it'd be more c-like
is the syntax c like too?
>>
>>55613343
I imagine library knowledge stems from a need to actually use the library followed by an internet search. Only a very small set of people would read libraries to memorize them.
Probably also blogs and tech talks.
>>
>>55613282
When I learned haskell I did this thing: https://github.com/bitemyapp/learnhaskell
I recommend it (particularly the Spring 13 CIS 194 it suggests) over LYAH, which I didn't like very much.

>>55613183
If you want to solidify your understanding of the standard typeclasses, the typeclassopedia could help: https://wiki.haskell.org/Typeclassopedia

Looking through the brick docs for the "extra things" I mentioned (Dialog, Edit, etc.), I think a good way to structure a brick application would be MVVM (Model-view-viewmodel https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel). The view would correspond to brick and Widget. The viewmodel would be the parts of your application state like Dialog or Edit that represent things that the user would interact with, and also would be the drawing and event-handling functions. The model corresponds to the non-view state your application has.

I think the built-in widgety things are meant both to be useful and to be an example of how to structure your own view components.

>>55613359
Rust has a lot of things normally associated with functional langs, like hindley milner types
>>
>>55613359
rust does not have C style syntax
>>
>>55611530
Well, I learned Haskell and... I just don't use it due to its type stronginess. I am comfy with more duck typing style.
>>
I fucking hate cabal, it doesn't even have an uninstall option, wtf?
I also hate that it fails constantly, what a piece of shit.
>>
>>55613379
I use haskell for its type strength/staticness. It makes it easy to find everything I need to change when I do a refactor that changes behavior enough that types change. In a dynamically-typed language you would have to write a billion unit tests to find them, or just go through all your code and find all use sites.

>>55613390
If you use plain cabal then it's recommended you do most project-specific things in cabal sandboxes. This unfortunately will result in lots of duplication of packages.

These days Stack is more recommended.

If you want to unfuck cabal you can remove all your installed packages by deleting (on Linux) ~/.ghc/architecturename-ghcversion
>>
>>55613379
>>55613410
Also all dynamically-typed languages I have seen lack pattern-matching, which comes in handy often. For example, representing the different message types you could get on some chat protocol. In a language without pattern-matching I guess you would manually tag the message and only set the fields that are defined, I guess, but pattern-matching leaves less room for error, and doesn't have the boilerplate of "if tag == "blah"".

Maybe Scheme could count as potentially having pattern matching if you wrote macros to do it.
>>
>>55613410
Generaly, I am frustrated about packing and unpacking Data.ByteString.Char8, Byte shits and others.
>>
>>55613438
(Or other lisps, especially ones with reader macros, but I've only used Scheme)
>>
>>55613438
Tru, I am missing pattern-matching in Python so much. It can be simulated with lambda-keyd dict in python, but it's not so comfy.
>>
>>55613373
it takes all the bad parts of c++ syntax tho
>>
>>55613448
>>55613458
I don't think the conversion issue goes away in Python by virtue of it being dynamically-typed. It tries to avoid implicit conversions (I think? except for numbers), so probably it only has one string type that is commonly used, so you don't need to do conversions.

I don't know your specific program, but lots of string type conversions might be a code smell, or it could just mean the libraries you used used different string types. In general, here are the use cases for them:

String (aka [Char]) - Generally you don't want to use this, even though this is the default String type that gets exported by Prelude. The only use-case that comes to mind is "iterator of characters".

Text (Strict) (from the text package) - This represents unicode text. Most of the time you should use this for representing text.

Text (Lazy) - This also represents unicode text, but it is broken up into chunks. Could be useful for streaming text like String. I'm not too sure on this one.

ByteString (Strict) - This represents literally vectors of bytes, in no particular encoding. It is not strictly a text type, but sometimes you might receive things or output things as a ByteString, for example network or file input/output. If you are working with binary data you should use ByteStrings.

ByteString (Lazy) - Not really sure, see Text (Lazy)

The lazy Text/ByteString are used for lazy IO, but I think lazy IO is pretty ugly and it breaks the pure semantics of Haskell. For streaming I/O you should go for a streaming library like pipes or conduit.

If you want to get terminal or file input as Text or ByteString, their packages provide functions for doing it without going through a String. This will also be more performant since you won't have to do conversions.
>>
>>55613535
Also I should note that it's fine to use String or lazy IO for simple things or experimentation that don't need to be fast or reliable.
>>
>>55613535
>>55613558
I like how you spent most of the post trying to blame the other guy's incompetence.

Haskell's ecosystem is fucked when it comes to text.
>>
>>55613661
I agree that it's fucked, but only because String is in the Prelude. I think Text and ByteString deserve to be separate types since they serve different purposes.
>>
>>55610731
the first sentence is so dumb
>>
>>55613196
yes, a succesful one too, I am still learning, 6 years later(24 now), did many apps, mobile, desktop etc, did around 30 sites for friends (the back and front end)

I have made 0 dollars so far, and I still work outside town in the kitchen of a roadside caffee
>>
>>55613762
>I have made 0 dollars so far

m8 how
>>
File: trash tour.png (20KB, 86x87px) Image search: [Google]
trash tour.png
20KB, 86x87px
>>55611465
>return ((x % 4)) ? false : true;
>>
>>55613937
better safe than sorry ;^)
>>
>>55613762
i have a certifcate of systems analyst. all i did was modify an existing apk that does what i wanted and then did the paper work and made sure it met the requirements to publish it on google. I started like a month ago but its been on my mind since march.

I hope to reverse engineer more apks in the future and hope to learn smali or at least convert it to java and modify some code or use it as a guideline to make my own.
I know how to read and spot code but im not familiar with what all the functions do, just the basics.
>>
>>55613352
this is my first time hearing about this. Might write a virtual machine/interpretor/recompiler myself. Looks like a fun project.

If you do write one do you have a git i can follow and help?

(you're writing one in C++/C hopefully)
>>
>>55613858
The place I am living is looking for senior guys only with 5+ years of exp, and the positions are around 50 or so, the area is practically a desert town in the middle of nowhere, I have to support my family and can't stop for more than a week or so for the whole year to focus on my projects, shit sucks, but I contacted an HR lady who is in charge of hiring ppl in one of those companies and she told me she will send my portfolio and CV to her boss or something, they are not even looking for senior guy, I hope the shit works, I will be happy for underpaid junior position so I can get my shit togheter and focus only on programming, get some work exp and actually pull a career out of that in the future
>>
>>55613973
Oh, hope you'll make it, Anon.
>>
>>55613973
that didn't explain how you've made zero dollars with your apps
even a flappy bird clone will make a dollar
>>
>>55613966
well, most "programmers" do this anyway,to make something truly amazing and functional from scratch you have to be turbo-9000 autist that started "coding" from 3 yo with pen and paper nowadays, and if you somehow manage to do this, you are going for a salary of 200k starting lol

so yeah, don't worry you are just fine, most places will offer you a job on the spot
>>
>>55613968

Well, I have a new job where c++ is used, so I could use this opportunity to skill myself.
Will post progress in some future /dpt/... maybe
>>
>>55613996
I don't have time to polish my "apps" and work for google, I work 12h a day and I do programming for the rest of my free time, and on the weekends I help my dad in his garage so he can make money too, if I have a month or so I could of publish at least 2-3 "apps" in the fucking store and hope to make a buck out of them.

As for the sites, they are for my portfolio, most of them are /wdg/ tier and pretty but functional blogs, in case there is front end or whatever end web dev job in the market near by. Even If I they don't cost more than a week salary combined anyway.

idk, I might be just dumb, and lazy, but at least Im not stopping, kek
>>
>>55614010
just curious but how much is this C++ job paying and what kind of work does it involve
>>
>>55614044
why not do some freelance programming online?
you'd at least make more money than cooking in some shitty cafe
plus there's no commute
>>
>>55614092
Next month I am taking around 12 days off in a row , 2 of which is working with dad but thats ok, its not 12h shifts so I'll have 10 days to make something, I am thinking of revisiting my old work and make it better, whats something that could generate downloads in the store ?

Also I have started with C++ recently and actually loving it compared to Pajava, (while most of my old work is in Java) so I am thinking of rewriting stuff to C++ but then again, how to make it mobile for android ? Does the android studio take good care of c++?
>>
>>55614135
Qt for Android?
>>
>>55614135
if you actually want to make money programming, then you shouldn't waste your time making apps

that's like trying to hit the lottery
>>
>>55610026
>type Listable a = (Bounded a, Enum a)
ffs
>>
it is a bad workflow to add "anti dumb" safety check (ei. the user inputting the wrong file, corrupted, etc) as last thing, when everything else is completed and working?
>>
>>55614091
$6/hour, 80 hours per month, Junior Python developer, but there is C++ stuff i have to know.
>>
>>55614239
I usually plan out my error checking system beforehand. It's pretty hard to inject it in already existing code (catching/throwing exceptions or returning/checking error codes) and it becomes too clunky.
>>
>>55612211
no, just use kan extensions and codensity if you want performance
>>
>>55610509
isn't that esoteric ?
>>
I'm writing a program that use a CLI program. I would like to take the output of it, but it doesn't work as expected since he still write stuff on the console. Any idea why ?

    int fd[2];
pid_t child;

child = fork();
if(child == -1) {
perror("fork error");
exit(EXIT_FAILURE);
}
if(child == 0) {
dup2(1, fd[1]);

execvp(list_args[0], list_args);
}
else {

}
>>
>>55614482
you need to read stdout of that program, use popen()
>>
File: 1389353920635.png (682KB, 522x604px) Image search: [Google]
1389353920635.png
682KB, 522x604px
>>55610026
Scrub here. I made an analog clock in Python.
I used Python as I don't know how to make windows with Java or C++: I did a digital clock with C++ in the console.
from tkinter import Canvas, Tk
from time import localtime, sleep
from math import sin, cos, pi

window = Tk()
window.title('Tkinter Clock')

canvas = Canvas(window, width = 640, height = 480)
canvas.pack()

#making a clock face
#for a more detailed clock face, add stuff here
canvas.create_oval(82, 2, 558, 478, fill = 'white')

#hands at midnight position
hourHand = canvas.create_line(320, 240, 320, 120, fill = 'blue')
minuteHand = canvas.create_line(320, 240, 320, 60, fill = 'red')
secondHand = canvas.create_line(320, 240, 320, 40, fill = 'black')

while True:
#gets time
seconds = localtime().tm_sec
minutes = localtime().tm_min
hours = localtime().tm_hour

#all the maths (might need checking)
x_sec = 200*sin(seconds*pi/30)
y_sec = 200*cos(seconds*pi/30)
x_min = 180*sin(minutes*pi/30 + seconds*pi/1800)
y_min = 180*cos(minutes*pi/30 + seconds*pi/1800)
x_hour = 120*sin(hours*pi/6 + minutes*pi/360 + seconds*pi/21600)
y_hour = 120*cos(hours*pi/6 + minutes*pi/360 + seconds*pi/21600)

#updates hand positions
canvas.coords(secondHand, 320, 240, 320 + x_sec, 240 - y_sec)
canvas.coords(minuteHand, 320, 240, 320 + x_min, 240 - y_min)
canvas.coords(hourHand, 320, 240, 320 + x_hour, 240 - y_hour)

window.update()

#reduces CPU usage by waiting
while seconds == localtime().tm_sec:
sleep(0.25)

###NOTES###

#1 second in 1 minute = 6 degrees = PI/30 radians
#1 minute in 1 hour = 6 degrees = PI/30 radians
#1 hour in 12 hours = 30 degrees = PI/6 radians

#Centre = (320, 240)
#Length of second hand = 200
#Length of minute hand = 180
#Length of hour hand = 120

#1 second in 1 hour = 0.1 degrees = PI/1800 radians
#1 minute in 12 hours = 0.5 degrees = PI/360 radians
#1 second in 12 hours = 1/120 degrees = PI/21600 radians
>>
>>55614692

C++ gui libraries to look into: MFC, wxWidgets, Qt

As for Java just use swing
>>
More of a math question than a programming question:

I have something that can contain a maximum of 15 "units" of something. The something (of which there are units of) affects a certain value over a period of time to an extent depending on how many units there are and the something itself.

I want to maximize this value. How do I write something to do that? Keeping in mind there are around 30 possible somethings, and when you combine this with the amount of units...
>>
>>55614848
the "pure" mathematical answer is that, if this "something" that varies in time is a direct function of the time and the other parameters, then you could study the derivative/gradient of that function and find its (global) maximum.
>>
>when you really need to do something slightly tedious/challenging but you come up with every excuse under the sun not to do it and once you've done all those other things you post a greentext about it in /dpt/ instead of actually getting started with it
;_;
>>
>>55614161
if you make shit apps sure
>>
>>55614919
what is this something?
>>
>>55610218
Python has lazy list generators, they are essentially anonymous generator functions. You write them just list list comprehensions, but instead of [...] you do (...). Then you can full evaluate it and put it in a list with list() or use functions from functools or itertools to only partially evaluate if it's an infinite generator.

>>55610131
it's p bad

rate mine
function Permutations(l, r)
local sel = {}
r = r or #l
sel[1] = 0
for i = 2, r do
sel[i] = 1
end
return function()
-- increment selector
for i = 1, r do
if i == r then
return nil -- all permutations found
end
-- if incrementing this position makes the result no larger than the max
-- this position can take (decreases up the array) from #l down to 1
if sel[i]+1 <= (#l-i+1) then
sel[i] = sel[i] + 1 -- increment position of farthest carry
break
else
sel[i] = 1 -- if carry then reset caried positions to 1
end
end
-- copy l
local lc = {}
for i = 1, #l do lc[i] = l[i] end
-- build perm from lc
local remove = table.remove
local p = {}
for i = 1, r do
p[i] = remove(lc, v)
end
return p
end
end
>>
>>55614537
gonna try that, thx.
>>
>>55614963
shader code to render from one texture to another with non-90 degree rotations as accurately as possible, will have "hard-coded" rotated local tex coords to select from instead of doing matrix rotations
>>
>>55614987
Just going to add... coroutines are the superior control flow device. I wish Lua had symmetric coroutines. You can emulate symmetric coroutines with asymmetric ones, and vice versa, but it's a lot easier and more efficient to use symmetric coroutines and abstract from there.

The coroutine library is fast in the JIT, but it isn't compiled. So I unrolled the logic above for speed. After reading the TAOCP this is essentially the plain changes algorithm.
function Permutations(l, r)
r = r or #l
if r > #l then return nil end
local indexes = {}
for i = 1, #l do
indexes[i] = i
end
local cycles = {}
for i = #l, #l-r+1, -1 do
cycles[#cycles+1] = i
end
local p = {}
local start = true
return function()
if start then
for i = 1, r do
p[i] = l[indexes[i]]
end
start = false
return p
end
for i = r, 0, -1 do
if i == 0 then
return nil
end
cycles[i] = cycles[i] - 1
if cycles[i] == 0 then
local t = table.remove(indexes, i)
indexes[#indexes+1] = t
cycles[i] = #l - i + 1
else
local j = cycles[i]
indexes[i], indexes[#indexes+1-j] = indexes[#indexes+1-j], indexes[i]
for i = 1, r do
p[i] = l[indexes[i]]
end
return p
end
end
end
end
>>
>>55614916
It's for a game.

Basically 30+ chemicals. Chemicals affect the health of the player depending on how long they have been inside them. You can combine chemicals, and if you have a good combination, damage output is very high.

Goes something like this

Cyanide = 5 damage every 2 seconds
Venom = 6 damage every 3 seconds

But the different chemicals decay at different rates. So one would be in the body for a short period of time and do more damage, while one would be in the body a long period of time and do lesser damage.

You can combine any number of chemicals but the maximum units is 15.

I'd basically need to test ALL combinations of chemicals and their units and see which causes the most damage at a certain period of time (let's try 10 seconds, 20 seconds, 30 seconds)

That's the issue. It seems like it'd be very hard to do that, because there are a huge amount of combinations.
>>
>>55615070
>You can combine chemicals, and if you have a good combination, damage output is very high.
If these 'good combinations' are random or non-linear, you have no choice but to try all possibilities.
>>
>>55615070
do the chemicals stack? because then there should be one chemical that's the best (or several that are equally good) for a specific time frame
>>
>>55615070
>>55615121
On a second look, I might have misunderstood, the dependencies are all linear. Look into dynamic programming.
>>
>>55615121
Ugh how would I even do that?
So we have 15 units. Lowest possible amount is .1 units Then we have 30 chemicals. Hypothetically speaking you could put in all 30 chemicals... ugh.

This is like trying to make a decision tree for chess.
>>
>>55615143
Yes they stack.
>>
>>55610026
rate my reverse polish notation
import Data.Char

rpn = read . head . h . words :: String -> Double
h = foldl f [] :: [String] -> [String]
where f xs n = let t = drop 2 xs
in case n of
"+" -> (assoc True (+) xs) : t
"-" -> (assoc False (-) xs) : t
"*" -> (assoc True (*) xs) : t
"/" -> (assoc False (/) xs) : t
_ -> n : xs
assoc b g | b = foo g . take 2
| otherwise = foo g . reverse . take 2
foo g = show . foldl1 g . map (\x -> read x :: Double)

keep in mind this is the first working attempt
I haven't optimized it yet
>>
>>55615181
If I understand correctly, the number of possible combinations is 44 choose 14.
>>
>>55615204
so if i understood it correctly that you can put all cyanide, then the max would be 5*2*units, because if you put all venom instead it would only be 6*3*units, or if you put e.g. half cyanide and half venom it would be (5*2*units + 6*3*units) / 2 which is still less than 5*2*units
>>
>>55615256
for 10 seconds

actually 5*5 not 5*2
>>
>>55610026
I have this string and need to remove everything except "Pepeman, hueman", "Spiderman" and "Moot". What is some elegant regex to do that job

Pepeman, hueman A B C  Spiderman B D  Moot EF  MON-FRI,-,
>>
>>55615256
Ah, I think I left something out, sorry. The amount of units doesn't just drop from say 15 to 0 in one second, it decays at a rate.

So: 1 Second, 15 units, 2 seconds, 14.8 units, etc etc.

Those damage values are not the real values, I just made them up on the spot. With the real values it DOES make more sense to switch around then just go straight one chem. Remember that while it may be less OVERALL damage, it still will do more damage in a short period of time.
>>
>>55614987
>>55615050

This looks terrible
>>
File: renderingfixed.png (19KB, 800x602px) Image search: [Google]
renderingfixed.png
19KB, 800x602px
Fixed the rendering that was bugging me in my chip8 emulator.
>>
>>55615366
Source? :3
>>
>>55615351
And this is important because health is low in this game, not in the thousands pool. It's 200 is the max health.
>>
>>55615370

It's ugly as fuck and not worth posting. I used this project to start learning Rust.

Literally never used the language before this.
>>
>>55615351
ok i'm not sure if i understand it but if you want to maximize the damage over a specific timeframe like 10 seconds i still think it would be best to only use whichever one chem does the max damage over that time.
>>
>>55612143
>Nothing can be both Monoid and Monad
All monads are monoids but you can't express that in Haskell's retarded type system.

That's another reason why programming isn't about languages.
>>
 45     ¦   def get_page(url):
46 ¦ ¦ get = urllib2.Request(url, headers=headers_)
47 ¦ ¦ html = urllib2.urlopen(get)
48 ¦ ¦ html = html.read()
49 ¦ ¦ for i ,n in html_entities.iteritems():
50 ¦ ¦ ¦ html = html.replace(i, n)
51 ¦ ¦ html = html.replace('\n',' ')
52 ¦ ¦ return html



work fine on https URLs but get this if it's just plain http:

Traceback (most recent call last):
File "iii.py", line 149, in irc
html = get_page(yt_url)
File "iii.py", line 47, in get_page
html = urllib2.urlopen(get)
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1227, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1197, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>



what am I doing wrong ? Pls
>>
>>55615370
>>55615391

-_- Fine.. Be gentle it's ugly

http://pastebin.com/iYC6PNwv
>>
>>55615354
Good code is rarely elegant.
>>
>>55615447
Cute, not ugly :3
>>
>>55610026
Serious question:

Why programming languages use the "function" and "object"/"class" metaphor, instead of just a simple "noun" and "verb"?

I'd personally could do with an intuitive imperative/declarative language which uses the noun+verb metaphor,
maybe with "adjectives" for java-style annotations (or types, maybe?)
and "adverbs" for verb qualifiers (eg. process (verb) concurrently (adjective))

I mean, it'd be much more intuitive.
>>
>>55611830

Learn C.
You will learn everything in less than six month. Except pointers.
You will probably get stuck learning pointers for years.
>>
>>55615448

Good code in this case would probably be using a optimized intermediate internal representation built on a finite state machine.

Not directly translating instructions one by one, piece by piece. I was being quick (Time investment wise), simple, and dirty.
>>
>>55615447
>http://pastebin.com/iYC6PNwv
what lang is that ??
>>
>>55615448
import Control.Monad
main = print $ replicateM 3 [0,3,4]
>>
>>55615497
>>>/lit/
>>
File: AnswerAnon.png (728B, 169x38px) Image search: [Google]
AnswerAnon.png
728B, 169x38px
>>55615515

Pastebin tells what language it is.
>>
>>55615430
>All monads are monoids but you can't express that in Haskell's retarded type system.
ugh, http://stackoverflow.com/questions/17205453/instance-monoid-monad
>>
>>55615409
We want the time it takes to kill to be as low as possible.

I'm probably just going to make a genetic algorithm.
>>
>>55615528
>>>>/lit/
I'm pretty serious actually.
Why call it a language in the first place, then?
>>
>>55615497
The J programming language uses that.
>>
>>55615578
>I'm probably just going to make a genetic algorithm.
That's not a good approach, this is an easy and tractable problem, use dynamic programming.
>>
>>55615509
Pointers are easy, but the C syntax is idiotic and the language confuses them with arrays.
>>
>>55615588
I'll look into that. Thanks based anon.
>>
>>55615497
OOP is trash, and function/object is normally done as verb/noun
>>
>>55615441
ur internet

Also, use requests
>>
>>55615497
Not everyone fell for the OOP meme.
>>
>>55610026
getting my head around pic related

also anybody knows if it-ebooks . info is kill?It doesn't work for at least 2 days, it was a pretty good site with good ebooks.
>>
>>55615522
perm = require 'Permutations'

for p in pairs(perm({'a', 'b', 'c'}) do
print('{'..table.concat(p, ", ")..'}')
end


You're right. Compartmentalizing code into libraries is more elegant. I should do that from now on.

>>55615514
Be thorough though.
>>
File: cover.jpg (678KB, 1075x1326px) Image search: [Google]
cover.jpg
678KB, 1075x1326px
>>55615636
*forgot pic
>>
>>55615588
>>55615599
This J thing is highly skewed towards array/matrix analysis, tho.

For a mathematician, the "function" is an ok metaphore, I guess.
>>
>>55615611
Same error
 get = requests.get(url, headers=headers_)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 71, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 57, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 585, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 467, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='rizon.net%02', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f624b0da5d0>: Failed to establish a new connection: [Errno -2] Name or service not known',))

>>
>>55615675
>host='rizon.net%02'
There's your problem
>>
>>55615675
show url you are tryin to get
>>
>>55615645
replicateM doesn't just do lists, it does any monadic action

replicateM 3 (print "Hi!\n")
>>
>>55615596
Anything I can look at to get an understanding of what dynamic programming is? I looked it up but can't think of how I would use it to solve this problem.
>>
>>55615695
The point.




Your head.

>>55615497
Well as soon as they did that they wouldn't be able to get students to understand why OOP should be used for everything and not just the problems where that relationship makes sense.
>>
>>55615351
let me get this right
a chemical c can do n damage per h seconds
and a chemical c has a decaying rate, meaning what?
do you mean that amount of chemical c determines how much damage?
>>
>>55615718
CLRS Chapter 15 or that guy's MIT course: https://www.youtube.com/watch?v=OQ5jsbhAv_M&list=PLfMspJ0TLR5HRFu2kLh3U4mvStMO8QURm
>>
>>55615746
that is the point my redditor newfriend
replicateM is not just a combination function, it's from Control.Monad

it's like calling filter 'just a library function' when used
>>
>>55615767
filter is a library function
>>
>>55615780
I know but it's not comparable to a function that does an exact task
>>
>>55611860
Here's some news... that's not functional programming anymore.
>>
Can I get the same grasp of FP if I learn Rust instead of Haskell?
>>
>>55615799
>what are monads
>>
>>55615811
No.
Not remotely.
>>
>>55615683
>>55615691
I think it has something to do with url redirection
>>
>>55615783
So you are saying implementing a permutation monad and using functions for fucking with monads is somehow completely different than implementing a function to do permutations... You know you still have to implement the permutation monad, It doesn't just *poof* into existence.
>>
>>55615783
repM n = sequence . replicate n

btw, how is stuff like getChar or putChar even implemented
>>
>>55615826
What are you on about?
I'm saying it's a function for working with monads, that just happens to produce the desired behaviour (combinations, not permutations) for the List monad specifically

>>55615828
FFI I imagine, or it could be done by the compiler
>>
>>55611792

LISP is the best language for beginners
>>
>>55615851
This is false in so many ways
>>
How much do you earn with your functional programming job?
>>
>>55615826
what are you trying to say?
>>55615862
nice trick question
>>
>>55615862
mad pussy
>>
>>55615902
in the beastiality sense maybe..
>>
>>55615838
https://sleepomeno.github.io/blog/2014/06/25/Explaining-the-Magic/
It isn't magic. I could implement the same behavior. But why would I? I can't see any other use for the functionality defined for sequence on List besides exactly the purpose of generating permutations. It was designed that way.
>>
>>55615862

Believe it or not there are actually functional programming jobs. It's just a very small market.
>>
>>55615964
pussy's pussy senpai.
>>
image folder merger in c# tht will show conflicting filenames and both pictures and let you make a new filename.
>>
>>55615976
replicateM 3 (print "Hi!\n")

So it was designed for permutations, despite being remotely the same as replicate (a function that repeats a list), and instead the coincidence is that it repeats IO actions?
>>
>>55615862
A lot more than with shit like Java, PHP or JavaScript. You need to have a lot more knowledge too, tho.
>>
>>55616030
*not remotely

replicate 3 'a' is "aaa"
replicateM 3 'a' is
>>
>The OpenGL ES Shading Language is type safe. There are no implicit conversions between types.
yet i don't even get a warning with things like muhvec4 *= muhfloat, shit's a fucking minefield of gotchas
>>
File: 1466332004523.jpg (17KB, 450x370px) Image search: [Google]
1466332004523.jpg
17KB, 450x370px
>>55616034
>I make $300k starting
Suuure Anon
>>
why does it work like that?
>>
>>55616041
*
replicateM 3 'a' is an error
>>
>>55616056
all combinations of 2 elements from the list

see the link in >>55615976
>>
>>55616056
Because.
>>
>>55616054
Who are you quoting?
>>
>>55614784
Cheers, fella. I'll get on to them right away.
I have to say, though, I had a stab at installing the SDL and SFML libraries for C++ a while back and... I got stumped so I'm not very enthusiastic about installing more libraries.
As for Java... I just remembered JFrame is a thing.
>>
>>55615862
Nobody in here is employed.
>>
>>55616050
nvm i'm retarded, of course you can multiply a vector with a scalar, it's assignment and function parameters that doesn't have implicit conversion
>>
So, I have this tkinter window that I want to update automatically..
The problem is that when I do it automatically, you you lose focus of the text field and can't type.
What should I do?
>>
>>55616030
The article's author makes a good point "what does it mean to do the action 'list'? multiple times". Well I'll tell you, they made it mean permute. replicateM calls sequence.
sequence ms = let k m m' = [x:xs | x <- m, xs <- m'] in foldr k (return []) ms


Tell me that's not exactly what the above function is doing.
>>
>>55615813
>> what are variables.

Pure functional has no variables.
>>
>>55616090
>I had a stab at installing the SDL and SFML libraries for C++ a while back and... I got stumped
How come? They're almost trivial to instal.
>>
>>55616132
To add. The print function you talked about above. What are all the permutations of a function with no return?
>>
>>55611465
Lel, why did you use templates for this
>>
>>55616132
To add one more thing.

The reason I didn't implement my permutation as such is because it would consume a retarded amount of memory. That's something I can give credit to Haskell. It automagically lazily evaluates (or at least I hope it lazily evaluates that. Try replicateM 15 [1..15]).
>>
I honestly barely get monads outside of IO.
what the fuck is the point of using bind on a list
>>
>>55616132
It isn't just for lists
>>
>>55616325
All possible consequences
Lists are non determinism
>>
>>55616280

Literally can be applied to any vector of generic objects (Has to implement the = operator for Reduce).
>>
>>55616147
https://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-State-Lazy.html
>>
I have a waveform data pointer for a synth
Can I point it somewhere to reliably get noise on output instead of using rand()?

App is for linux.
>>
>>55616352
Classes?! Are you 'aging a giggle mate? This shit ain't pure functional programming.
>>
>>55616430
>I didn't understand so I'll pretend to have been pretending to be retard
>>
>>55616430

The Haskell fans on dpt seem to believe that the hacks to allow manage mutable state / side effects are "pure functional".
>>
>>55616463

to allow managed* mutable state. I seriously need my morning coffee.
>>
>>55616417
reading /dev/urandom?
>>
>>55616463
>hacks
it's not complicated, you take an extra parameter (initial state) and return a tuple (output, final state)
then when you chain stateful computations, you feed the final state from one computation into the initial state of the next
>>
>>55616515

Containing and managing impure code doesn't make it pure. Any useful language will have side effects and state changes at some point in order to be useful.
>>
>>55616513
Nah, it has to be some place in memory. It'd save me some work because my synth voice setup is

short *waveform
unsigned int waveform_len;

and I have code already for reading other waveforms from that data
>>
>>55616613
Haskell isn't pure, but the state monad is a pure form of stateful computation
>>
New to C

I have three files, one with main, another with some functions I need and a header with the same name

Right now I'm putting the function definitions in the header and writing them in the .c file so that I don't get implicit declaration errors in my main file. Is this how it's supposed to be done? I'm just including the header file in my main file.
>>
File: Web-designing.jpg (1MB, 4410x3402px) Image search: [Google]
Web-designing.jpg
1MB, 4410x3402px
Hey guys,
I'm new here. How do I into programming,.
>>
>>55616793
Web design is not programming.
Read SICP.
>>
>>55616652

Fair enough. Impure operations are just often expressed as monads .
>>
File: 1420112907201.png (243KB, 550x535px) Image search: [Google]
1420112907201.png
243KB, 550x535px
What's wrong with using memes in your project names and graphics?

Why not call your compiler PepeCC?
>>
>>55616167
Right, I'll have to remind myself what I did and what I followed...

With SDL, I found the instruction on the website useless. It took a lot of googling before I found http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/mingw/index.php with which... well, it works.
I only followed up to the Make files bit where I went "sod it" and gave up (looking over it now, I believe I can make headway with those Make files, now knowing that MinGW has an exe for them).
I think I remember SFML said it wasn't compatible with the MinGW version I'm using so I didn't even get that far.
>>
>>55616858
Autism
>>
>>55616861
>windows
>problems with a build system
Checks out.
>>
Well since this thread isn't dying just yet, what's the intended way to use Docker containers?

Am I supposed to have a separate container for Python, one for Postgresql and so on, or put everything in one container/Dockerfile and develop my stuff using that?
>>
>>55617113

Wrong place for this question

You might find more help in
>>55574020
>>
if read()'s return value is the number of bytes read, does that value contain the null-terminated character? I'm reading from a terminal.
>>
>>55617206
>does that value contain the null-terminated character?
There is no null-terminated character.
>>
>>55616071
Because of the wonderful things he does.
>>
>>55610026
FUCKING GOOGLE JESUS CHRIST
>>
New thread: >>55617401
>>
>>55617402
more context
>>
>>55617402
>>55617413
fucking kikes
>>
>>55617402
>>55617413
Why only teen girls?
>>
File: CXZMgaLWAAA8zMW.jpg (269KB, 1024x1448px) Image search: [Google]
CXZMgaLWAAA8zMW.jpg
269KB, 1024x1448px
>>55617425
""""""""equality""""""""
>>
>>55617425
because MUH OPPRESSION

I seriously don't know. It's the ultimate retardation

please don't teach more people that they can code. I've experienced it myself, a lot of people are complete shit even if they want to learn
>>
>>55617450
it's the globalist jew agenda
>>
>>55617420
>>55617462
gb2/pol/ pls
>>
>>55617249
I mean, if i take input from a console with read, will it return the number of characters read + 1 for the null character or juat the number of characters read?
>>
>>55617509
SHUT
IT
DOWN
>>
>>55617529
>will it return the number of characters read + 1 for the null character
There will be no null character.
>>
>>55617530
>I'll just spout memes instead of substantiating my claims
>>
>>55617542
But arent cstrings ended with a null char?
>>
>>55617551
https://www.radioislam.org/islam/english/jewishp/internet/jews_behind_internet.htm#google
>>
>>55617574
They are, but read() (if you mean the POSIX one) does not give a C string. It gives the raw input.
>>
/dpt/ is 90% muslim
>>
>>55617623
90% poo in loo
>>
dindus, mudslimes, pajeets, and judens. GAS THEM ALL
>>
>>55611782
Either I just suck at vector/matrix math or the last time I used that header it was buggy as shit.
Not to mention non-existent documentation.
>>
>>55615430
I meant the Haskell typeclasses, dummy.
>>
>>55616771
prototypes for the functions in your header file
functions in whatever.c
and in main.c, you #include "header.h".
>>
>>55617447
Can you give sources for people who actually say """White""" must be turned into a minority to solve racism? I know people say that being a majority results in racism, but that's not the same as saying that it is the direct cause and the only way to reduce racism is to reduce the white population.
>>
File: 1448380572619.jpg (298KB, 1516x810px) Image search: [Google]
1448380572619.jpg
298KB, 1516x810px
>>55618421
>>
Why would one use C# over Java?
>>
File: (20).png (51KB, 240x232px) Image search: [Google]
(20).png
51KB, 240x232px
>somebody cloned my github repo
>>
>>55618497
The context of Arthur's quote looks like it is about representation of "non-white views" in media, which is far from saying he supports white genocide.

Tim's quote is certainly anti-white, but it sounds like he views white genocide as a natural process, not something he is actively pursuing. The context is he is trying to tell the "white right" (his words) that their positions are based on fear and don't make sense. He was trying to BTFO people, not advocate white genocide.

Wikipedia page for Noel says that he wants to exterminate white as a social identity, rather than remove white people. That may be just as bad to you, but it's not the same as turning all white people into brown mixes. It might also be him backpedaling after his quote, but it's still his public position.

Orthodox Jews are known for their extreme beliefs, I will give you that one. It's unfortunate that they carry so much influence in Israel. I think these quotes are about Jewish superiority though, not about removing white people.

Susan says (according to Wikipedia) that the white race is a cancer because of their inventions and ideologies. So it would be consistent with what she said to say it's possible to remove the cancer without white genocide, by changing ideology.

tl;dr the poster implied everyone said those things in support of white genocide, while in context that is not really true. Some of the quotes taken in context might not even say that they are anti white people (but still anti white culture)
Thread posts: 355
Thread images: 23


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