/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?
Old thread:

Other urls found in this thread:

grammarly.com/
youtube.com/watch?v=tpIctyqH29Q&list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo
docs.python.org/3/library/functions.html#open
lmgtfy.com/?q=lisp os
wiki.c2.com/?LispOs
twitter.com/AnonBabble

Linear types will save systems programming

C++ is good enough

fuck opengl

renaming video files to the title stored in metadata (if exist) with [spoiler]rust[/spoiler]

You have 0.1 seconds to justify Rust's right to exist.

C and C++ are bad

Learning python. I can't figure out how to check an input string.

>C and C++ are bad
That's not an excuse to produce another bad language.

pic related

there are several problems here. i don't understand calling input(pop). just check whether pop is equal to "y"

I really appreciate that, thank you. It worked. I am going through Sup Forums's list of programming projects for noobs. This was my first. 98 more to go.

Trying to replicate Sonic guy's game physics. It's a little trickier than standard Mario-style stuff.

two more things. one is a quibble: you don't need parentheses around "y"
more seriously, i don't see why name_gen should be a class, as things stand

yeah srsly
ur var naming is shit
next time screenshot with line numbers so this can be over faster:
- pop = input("sum shit y/n")
that should be "response = input(...)"
- response = str("y")
that should be "expected = "y""
- if input(pop) == str(response)
wtf
input(pop) means "print out `pop` and wait for the user to enter shit"
str(response) is converting response(which is already a string) into a string
just do `if response == expected_response: shit
else: get bent`

Btw you can use random.choice(name) to get a random element from the list.

again, turn on line numbers when screenshotting
if (pop) == ("y"):

unnecessary parentheses, you can do just
if pop == 'y':

looking to swap a site with a Laravel application.
think I could do it in a day?

better?

so is this where the autists hang out?

nah, that's the discord

1. I got a dig bick
2. You that read wrong
3. You read that wrong too
4. You checked
5. You smiled
7. You are wondering why you're still this reading this
8. You saw that mistake... right? (On 7)
10. But did you see that I skipped 6?
10. You checked
11. And saw you that I doubled 10 and skipped 9
12. I said saw you, not you saw
13. I also skipped 2
14. You got tricked
15. I'm just wasting your time go back and read other coments...

It doesn't suck as much as go and looks better than c++

>looks better than c++

my sides

heheheheehe, good one user.

>better?
- lines: yes
- code: sure
but line 15 still has a pair of useless parentheses around `response`
did you just forget to remove them, or do you think you need them - and if so, why?

I'm trying to web scrap some pages in Python and it's not working. I don't know what to do anymore.

do you find the class as strange as i do?

answer = random.randchoice(name)

whats the difference between all those meme languages?

running without it being class but a function instead...what else should it be?

rust: array.iter().map(|el| el + 2).collect()
c++: for_each(array.begin(), array.end(), [] (int i) -> int { return i + 1; })

-> int

It prints what I need in console but writes only the last page to file. Pic related
Why it doesn't write all pages to file?

In C++ this is just:
for (auto &x : array) ++x;

>rust: array.iter().map(|el| el + 2).collect()
>c++: for_each(array.begin(), array.end(), [] (int i) -> int { return i + 1; })
C: for(int i = 0; i < n; ++i) arr[i] += 1;

most probably you are rewriting the same file in every iteration, thats why u end up with only last page written in file faggit

which feature set is circlejerked as the solution to all possible problems

(since c++14)
ofc. c is better.

>>rust: array.iter().map(|el| el + 2).collect()
>>c++: for_each(array.begin(), array.end(), [] (int i) -> int { return i + 1; })
>C: for(int i = 0; i < n; ++i) arr[i] += 1;
Scala:
xs.map{_+1}

bloody hell

what languages do hackers know?

Well I figured that, but how do I do it right? Pls help, mister. I wrote the write function in and outside of the loop as well as close. I just don't know anymore.

since c++11 friendo

use open(filename, "a", encoding="utf-8") instead

Hello. Is there an open source code for something like this grammarly.com/ ?
I'm not a programmer but more like the linguist-sort of person. I'm not a native English speaker but I want to develop a similar system that have the function almost exactly as the website but in my native language.
>editable grammar rules
>adding dictionaries

are you white?

God bless you it's working fine now. But why 'a'?

>rust: array.iter().map(|el| el + 2).collect()
>c++: for_each(array.begin(), array.end(), [] (int i) -> int { return i + 1; })
>C: for(int i = 0; i < n; ++i) arr[i] += 1;
>Scala: xs.map{_+1}
Lisp:
(map xs 1+)
Game over.

hopefully the ones they need, and parts of ones that have improved them as hackers/engineers/programmers
that's why CS/IT undergrad introduces you to the wider landscape, so you're not stuck in a narrow-minded POV, thinking "that's the only way I've seen it one"
e.g.
C
C++
Java
FP wankery (lisps, haskal, scala)
logic wankery (prolog)
low-level shit (asm, etc)
and ideally some history (FORTRAN, ALGOL, etc) so you're not doomed to repeat it
speaking of which, highly recommended for noobs:
youtube.com/watch?v=tpIctyqH29Q&list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo
Crash Course Computer Science
cringy and memey plenty of times, but it's got a very good (and fast paced) overview of "why", the history of computation, software, hardware

return 'answer'. then print the result of name_gen()

docs.python.org/3/library/functions.html#open

its mode when the file is opened, and everything is appended behind the existing shits in that file..

if you are using just w it rewrites whole file evritime

>lispcuck
>smug despite other langs already being better
shocking!
haskal does it better

I see thanks.

thx

>for_each(array.begin(), array.end(), [] (int i) -> int { return i + 1; })
>array.iter().map(|el| el + 2).collect()
> xs.map{_+1}
>somehow better than (map xs 1+)

No. I'm Bornean.

You forgot to add Rust after Lisp

What do you think "linear types will save systems programming" is referring to?

(OP)
I finally finished learning a few languages and some database side stuff. Java, c++, sql, php, all web stuff and some weird programs.

Deciding on making an app, I dont really have much of an idea but at least trying to make a calculator. You guys got any suggestions on where to learn this and what software

nice reading comprehension

Why does there exist no good systems programming language?

I am trying to take a numpy array, keep the same number of rows, but look at the last variable set of information.

def mainlogic(coin):
work = np.loadtxt(coin+".txt")
nineper = work[:][int( len( work[0][:] ) *(.09*-1) ):]
foteenfiveper = work[:][int( len( work[0][:] ) *(.145*-1) ):]
totreesixper = work[:][int( len( work[0][:] ) *(.236*-1) ):]
treeatetoper = work[:][int( len( work[0][:] ) *(.382*-1) ):]
fiddyper = work[:][int( len( work[0][:] ) *(.50*-1) ):]
goldenper = work[:][int( len( work[0][:] ) *(.618*-1) ):]

but every time I check len(anyarraysubset) they are all the same? and if I mess around with the ordering of the slicing, it returns an empty set. I think I am misunderstanding how to get the proper slice. The coin.txt file will constantly be growing, and I wish to be analyzing each slice of the array separately. I'm self taught, and I can't seem to find the right stackoverflow response.

>>rust: array.iter().map(|el| el + 2).collect()
>>c++: for_each(array.begin(), array.end(), [] (int i) -> int { return i + 1; })
>>C: for(int i = 0; i < n; ++i) arr[i] += 1;
>>Scala: xs.map{_+1}
>Lisp: (map xs 1+)
Haskell: map (+1)

void *p = fn();
void *a;
{
void *p = p;
a = p;
}
a == p; // false

send help

>void *p = p;
dude... what

are you being retarded on purpose?

are you? This doesn't do what you think it does.

Leave it to the Hasklet to fail to grasp the difference between a function and a list.

It should create variable named p in the block and set it to the value of outer p.
Anything else would be fucking retarded.

if you're working with tabular data but not too much of it i recommend using pandas

>Anything else would be fucking retarded.
No, user. What you're proposing is fucking retarded.

The inner p has already been introduced into the scope, it's already shadowing the outer p. Read a book nigger.

Holy shit C is so fucking retarded.
Here let me show how proper language works.
(let ((x 10) (a 3)) (let ((x x)) (setf a x)) (print x) (print a))

10
10

>c++ommon lisp
get that dysfunctional garbage out of here

WHY does it seem to be the standard thing both online and in school to teach object-oriented programming in such a superficial way? Why do they use shit like "class Dog extends Animal" as examples and not something you would REALLY use in actuality? I want real-world learning materials, not some bullshit like "ok class today we are going to build a celery farm, let's start with class Farm and work from there :^)"

It's easier to understand the concept with such analogies, supposedly.

>Here let me show how proper language works.
>(let ((x 10) (a 3)) (let ((x x)) (setf a x)) (print x) (print a))
wow, I never realized lasp is so readable

There is literally no problem with the Common Lisp language. Respect Common Lisp.

cuz thinking up proper, practical examples requires effort
it's much better to introduce you to inheritance in the context of a e.g. (self/group) project, where you can see the retardation it replaces
not this cat dog useless bullshit
did that with a friend who's starting on the autism track, works much better

imperative lisps are sin

Building anything in the real world is an imperative process.
God created the world and made it imperative.
Imperative programming is modeled after God's creation.
There is nothing sinful about imperative programming.

>list cultists gonna cult

>God created the world and made it imperative.
Wrong. God just defined the world and then forced evaluation.

what the fuck

From what I understand emacs is basically a lisp interpreter and every functionality is implemented in lisp right?
would it be possible to create a toy os with a similar architecture?
I have the os course tomorrow so I don't know a whole lot about them, except for virtual memory stuff that we learned in the comp architecture class

What programming languages a white male should known to stop being a CIA nigger pajeet.

>What programming languages a white male should known to stop being a CIA nigger pajeet.
Lisp.

It's called a reflexive programming environment.
TempleOS is an operating system with such architecture with holyC as the programming language.

lmgtfy.com/?q=lisp os
------------>
wiki.c2.com/?LispOs
hows dat for spoonfeeding

So I got a list of strings and a number that corresponds to an element in said list.

Getting the element from the list by only using hd and tl in SML feels tedious as fuck. Am I missing something? In any other language this would be a o(1) operation.

doesn't SML provide some sort of an indexed sequence data type?

So whats the point of using lua with C.
Why would you want to use both, rather than one or the other depending on the use case?

Every bigger C or C++ projects ends up implementing some kind of scripting system into it because you don't want to compile big project again and you need to test stuff at runtime.
You could compile C at runtime and load the shared library but dynamically typed scripting language is still at least bit faster to use.
People are using lua because somebody on the internet said to use it and they don't know better.

I have a C++ program that I want to run in my CPU and GPU at the same time, can I just use OpenCL to concurrently execute the for loop that is in use 99% of the time? It's just number crunching with some random number generation, so it's just pretty much C code anyway, I can just use it as the OpenCL kernel right?

Can someone explain CMake to me? What it is and what it does?

have you considered the involved data transfer overhead (bandwidth and latency), including synchronization?

It's just a small array (barely one or two MBs).

what if
javascript as a scripting lang for a game

ah, right-o
then I guess you have some pretty-big-O complexity algo if you need the GPU for 2MB of data?