/dpt/ - Daily Programming Thread

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

fuck opengl

Lisp is the most powerful programming language.

what are good c projects besides memory editor

game engine
window manager
vm for some bytecode

Because it reminds them how useless their memelangs are.

Probably true, but it's not always the best tool for the job.

C compiler

good op

Dude literally every program is a memory editor.

deep

How many people actually use the term "full stack"? Is it a webdev meme?

Who should into lua and why?

Building a simple neural network to solve an AND logic gate in matlab. Can I ask about how I would go about converting it into a XOR (exclusive OR) logic gate? I know I have build a hidden layer for it but I'm not sure how.

AND_In = [ [0;0], [1;0] , [0;1], [1;1]]
AND_Out = [0 0 0 1];

XOR_In = [ [0;0], [1;0] , [0;1], [1;1]]
XOR_Out = [0 0 0 1];

Weight = randn(1,2)

for i = 1:4
vec = AND_In(1:2,i);
C = Weight*vec;
if(C > 0.5)
Output = 1
else
Output = 0
end
end


Thanks in advance.

I hate my job but I won't be able to find anything better

what do you do

Full stack web developer

SOMEONE HELP ME! I JUST STARTED JAVA AND I CANT GET THIS PROGRAM TO LOOP AS DO WHILE STATEMENT! AND HAVE THE CONTINUE STATEMENT LOOP UNLESS USER TYPES 'N'!
REE!

import java.util.*;
public class Q2 {

public static void main(String[] args) {
Scanner UserInput = new Scanner(System.in);
Q2 obj = new Q2 ();
obj.acceptnumbers(UserInput);

}
public void acceptnumbers(Scanner k) {
int x;
int y;
System.out.println("Do you want to continue? Enter n/N to stop or Y/y to continue");
String answer = k.next();

while(answer.charAt(0) == 'y' || answer.charAt(0) == 'Y'){

System.out.println("Enter your first number");
x = k.nextInt();
System.out.println("Enter your second number");
y = k.nextInt();
int total = x*y;
System.out.println("The values " + x + "and" + y + "multiplied are" + total);
}

while (answer.charAt(0) == 'n' || answer.charAt(0) == 'N');


}


}

but I heard that js artisans get all the money and hot chicks these days

you're gonna feel like even more of a retard when you see the mistake.

Not a java fan but is that main creating an object of the same class? What is going on here?

java is such a terrible language for teaching beginners

What's the difference between the MIT license and public domain?
Is the MIT license more NAP or Communism?
Is public domain the ultimate form of freedom or corporatism?

craftinginterpreters.com part II

Is there some Rust mentor on YouTube or Vimeo.
I need a mentor.
Help anons-chan.

Public domain is the ultimate freedom even claim it as yours.
MIT means it is always licensed to X but you can do whatever to the product with no warranty.

I have 0 knowledge of Java but shouldn't it look like
do
{
body
question
}while answer

tldrlegal.com

First of all: why are you creating a new Q2 object? You can invoke methods inside the same class directly, without necessary using another object. It will simply call the method on the object itself.
Second: indent your code properly, for Our Lord's sake, and spotting errors will become much easier.

Huh, so the MIT license is only a watermark.

>Keep getting a stack overflow exception
>Spend an hour trying to figure out why
>Fiddling with code
>Googling shit
>Still can't figure it out
>Suddenly realize I'm accidentally calling a method from within its own body and that was the only problem
>Wasted a whole hour for no reason

; arg 1 = edge list ({int dest, int src, float weight}[])
; arg 2 = number of edges (int)
; arg 3 = source vertex (int)
; arg 4 = output vector (float[])
; arg 5 = number of vertices (int)

bellford:
test edx, edx
jz .endncloop

push ebx
push esi
push edi

mov eax, 0x7FF00000
mov ecx, [esp + 32]
mov edi, [esp + 28]
rep stosd

mov ecx, [esp + 24]
mov edi, [esp + 32]
and [edi + 4 * ecx], 0

mov ecx, [esp + 32]
dec ecx
jz .endncloop

mov eax, [esp + 20]
test eax, eax
jz .endncloop

shl eax, 2
mov edx, [esp + 16]
mov ebx, [esp + 28]
lea eax, [eax + 2 * eax]
add edx, eax

.mainloop:
mov edi, [esp + 16]

.preedgeloop:
mov eax, [edi]
movss xmm0, [ebx + 4 * eax]

.edgeloop:
mov esi, [edi + 4]
movss xmm1, [ebx + 4 * esi]
addss xmm1, [edi + 8]
minss xmm0, xmm1
add edi, 12
cmp edi, edx
je .endedgeloop

cmp eax, [edi]
je .edgeloop

movss [ebx + 4 * eax], xmm0
jmp .preedgeloop

.endedgeloop:
movss [ebx + 4 * eax], xmm0
loop .mainloop

mov edi, [esp + 16]

.prencloop:
mov eax, [edi]
movss xmm0, [ebx + 4 * eax]

.ncloop:
mov esi, [edi + 4]
movss xmm1, [ebx + 4 * esi]
addss xmm1, [edi + 8]
comiss xmm1, xmm0
jb .nc

add edi, 12
cmp edi, edx
je .endncloop

cmp eax, [edi]
jne .prencloop

.endncloop:
mov eax, [esp + 16]

.end:
pop ebx
pop esi
pop edi
ret near 16

.nc:
xor eax, eax
jmp .end


I promised I would implement Bellman-Ford in x86-32 assembly (stdcall convention), and here it is, though I don't know if it works. Probably doesn't.

>2018
>posting frogs
anons

Stupid frogposter; kill yourself.

>still complaining about frogs
We already won, animefags. This is OUR website now.

...

>implying the two are mutually exclusive

What are some areas that LISP isn't appropriate for, aside from systems/embedded programming.

here's my hint user, this should be your final output.

literally everything except making more lisps.

10 pages away from finishing The Little Schemer

feelsgoodman

going to work through The Seasoned Schemer next and then common lisp shit after that. idk why, doesn't even help me with my job, but it just feels good to work with

> no input or output methods of any kind
Do it properly or dont do it at all.

programmable programming languages when?

dumb frogposter
go back to

Guys, I was given this as homework, but I don't know how to do it.
>Make a function that returns a prime factorization tree of a number
>e.x. factor_tree(60) returns [60, 2, [30, 2, [15, 3, 5]]]
halp

Maybe some hard realtime applications but usually you implement some library with sepples and then script the rest so lisp with ffi would kind of work there.

any compiler + proper translexer.

What's the proper terminology for "non-conservative type system"? (a type system where you use more than static type information to make judgements)

I don't think I'm looking for "dynamic type system". I think that would just be a subcategory of what I'm looking for.

Learning C, wrote a number guessing game as practice. How did I do?

#include
#include
#include
int main(){
printf("What number between 1 and 10 am I thinking of? ");

int iRandomnum = 0;
int iResponse = 0;

srand(time(0));

iRandomnum = (rand() % 10) + 1;

scanf("%d", &iResponse);

while (iResponse = 10){
printf("No, guess a number between 1 and 10! ");
scanf("%d", &iResponse);
}

if (iRandomnum == iResponse)
printf("Wow! You got it right!");
else
printf("Oh no, you got it wrong! I was thinking of %d.", iRandomnum);


return 0;
}

Why should we?
How about YOU leave if you don't like frogposting?
You represent the old and bygone, we the frogposters are the men of present AND future.

Shut up I hate you.

frog website

I want a hash map with pointers to different types of objects. in java this is trivial but how do you do that in c++?

a shit. do hot and warm approach.

you can't do that in sepples, use C instead.

You can't really fuck it up so pat yourself on the back.

It's a learning tool not a challenge.

explain the output

>you can't do that in sepples, use C

...

Hungarian notion is stupid.

I want to make a buck or two from making school tasks.
How can I do that?

>base abstract class
>struct/class
>void ptr
>boost::any | variant
Why the hell would you do that though?

I more meant am I doing anything as far as using proper styling standards and whatnot, but thanks lol. Suppose I should have been more clear on that.

Okay. The upper bits of rand() are 'more random' than the lower bits so it's usually to better to take as few of the upper bits as you need rather than keeping the ones' place through modulo.

You could also have typed one less scanf by making the while loop a do-while loop and removing "No, " from the prompt.

You already said the main ones, but also real-time.
I worked on real-time systems for about two years, most applications required BY CONTRACT stuff like never, EVER using dynamic memory allocation and limiting the use of pointers (I used C most of the time, and sometimes Ada).
You don't really have such control over memory layout with Lisp. It's a great language, but for such situations it's completely out of the question.
Just don't cripple yourself by wanking over any language and use the right tool for the right job.

>t. Romanian

holding loaded assets of different types in a single hashmap

If it's a closed set of types, maybe use a std::variant.

Alright, thanks. exactly the kind of feedback I was looking for.

void pointer + typeid or a shared base class with some kind of enumerated type identifier...

so two ways of doing the same thing I guess

*void seems the right thing. the type of the object can be easily deducted from the filepath.

Sure, if you can recover the type another way that's fine.

gimme a sec

Fuck off how dare you steal parts of my answer

We weren't, just suggesting the best course upon clarification.

just use greedy algorithm method.
either manually or bruteforcely generate an array of prime number in ascending order, then in a while loop modulus the input with the prime in the array from the index 0. if the modulus is 0 then divide it and increase the count for the number by 1, if not, then increment the index and redo the loop. you also need to check whether the program is equal to the prime number to know when you need to terminate the function

What exactly are these "school tasks" you want to make?

If you need that prefix to remember what type your variables are, it means your function is way too long.
Their type should always be clear from the context and easy to remember given the short function length.

Anons, why is ruby so slow

[CODE]
test.rb:

#!/bin/ruby
puts "hello\n";

test.pl:

#!/bin/perl
print "hello\n"

test.sh:

#!/bin/bash
echo "hello"

[user@anon-pc ~]$ time ruby test.rb
hello

real 0m0.110s
user 0m0.097s
sys 0m0.010s
[user@anon-pc ~]$ time perl test.pl
hello

real 0m0.005s
user 0m0.004s
sys 0m0.001s
[user@anon-pc ~]$ time bash test.sh
hello

real 0m0.010s
user 0m0.008s
sys 0m0.002s
[/CODE]

what language lets you nest disparate types (integers and an array) inside an array like that? Ruby?

Without a limit on the number of known primes to check this program will grind to a total halt. Might want to get clarification of that first, otherwise you need to write two programs, one to do the task and the other to generate the primes.

Because of the overhead needed for absolutely everything to be an object in an interpreted language

> what language lets you nest disparate types (integers and an array) inside an array like that? Ruby?
Python

> Without a limit on the number of known primes to check this program will grind to a total halt. Might want to get clarification of that first, otherwise you need to write two programs, one to do the task and the other to generate the primes.
Read the task again.

I had a typo in my response, I said two programs when I meant two functions. Maybe that clarifies?

Okay, so suppose I input a number that is 2*(some 10 digit prime number). How *won't* that grind to a halt?

I mean the the task doesn't say the function has to be good, but you're not really learning shit if you learn to do it poorly.

Most languages that aren't statically typed autism. Python, Ruby, Perl, any Lisp...

but perl is OO, so is python

[user@anon-pc ~]$ time python test.py
hello

real 0m0.060s
user 0m0.052s
sys 0m0.007s

why is perl so damn slow just to write "hello world" on the cmd line

>scripting languages are slow and shitty
wow, thanks for the breaking news.

It will not grind to a halt it will just be very slow. And since nothing about speed is stated in the task its probably ok. It's probably some homework task that should handle simple input fine.

i'unno probably better implementation and typing that isn't quite as dynamic as Ruby

Semantics, by grind to a halt I mean it might finish but take 10 million years to do so.

someone do the rest
from sympy.ntheory import factorint
target = 60
res = factorint(target)
factors = [i for i in res for j in range(res[i])]
print (factors)


output
[2, 2, 3, 5]

#!/bin/bash

match=$(printf "%$1s" | tr ' ' 'a')
regex=$(printf "%$1s" | sed -r 's/ /a\?/g')"$match"

echo "Using regex $regex"
echo "Matching against $match"

echo "grep"
time grep -E "$regex"

def leastPrimeFactor(n):
if (n&1 == 0):
return 2
d = 3
while d*d

...

holy mother of god

let rec is_prime n =
if n < 2 then false
else let rec aux div =
if div >= n then true
else if n mod div = 0 then false
else aux (div + 1)
in aux 2;;

let next_prime n =
let rec aux n =
if is_prime n then n else aux (n + 1)
in aux (n + 1);;

let factor_tree n =
let rec aux_factor_tree curr_n curr_div =
if curr_n mod curr_div 0
then aux_factor_tree curr_n (next_prime curr_div)
else let quotient = curr_n / curr_div in
if is_prime quotient
then Leaf(curr_n, curr_div, quotient)
else let subtree = aux_factor_tree quotient curr_div
in Tree(curr_n, curr_div, subtree)
in aux_factor_tree n 2;;

You don't belong here btw, you worthless cheating sack of shit. I only did your exercise because I found it to be a fun little time waster.

f may also be a type, in which case f might be invoking a constructor of f. Or a conversion operator for whatever xs type is. Or if x is also a type, then it's a function declaration.

Here's another one for a frame of reference:
$ ./test_regex.sh 32
Using regex a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Matching against aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
grep
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

real 0m0.004s
user 0m0.002s
sys 0m0.002s

perl
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

real 3m17.484s
user 3m16.838s
sys 0m0.169s

ruby
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

real 0m46.258s
user 0m46.116s
sys 0m0.026s

This is what happens when you skip your CS classes.

retard

I was considering learning ruby for web dev. Heard it was bretty to pick up and start quickly. Whats a better alternative

It is easy to learn and use tho, it's just painfully slow on runtime.

If everything is an object then everything down to methods and the strings need to be instantiated before they can be used. How is that not overhead compared to how C would do things?