/dpt/

last

Other urls found in this thread:

idris-lang.org/idris-1-0-released/
twitter.com/SFWRedditVideos

Lisp is the most powerful programming language.

Maybe if you don't count Haskell

Maybe if you don't count C#

>Valiente

Time to go back Pablo

Maybe if you don't count Java

Maybe if you don't count C

Added bookmarks to my reader:

collinoswalt.com/res/test.webm

saves [filename.txt].bookmark to ~/.books/bookmarks

Maybe if you don't count C--

Maybe if you don't count Visual Basic

Wow... SICP is FUN!

Thanks /dpt/

Maybe if you don't count C

What is wrong with this haskek program

it is supposed to return the amount of hailstone sequence iterations a number takes to reach 1

hail :: Integer -> Integer -- takes one integer returns 1 integer
hail n | n Integer -> Integer -- takes in two integers, returns one integer
nextiter n i | odd n = nextiter (3*n+1) (i+1)
nextiter n i | even n = nextiter (div n 2) (i+1)
nextiter 1 i = i -- "return" i when it reaches 1

The problem is it's Haskell

uncultured swine

>hail n | n

Because the Integer type is arbitrary precision in Haskell

to get unsigned integers you have to import some shit from something and I don't feel like it

bump

Maybe if you don't count shell

...

Maybe if you don't count 卐Python卍

dude should shave

dynamic linking was a mistake

Windows was a mistake.

Should nextiter 1 i comes first?

you can link staticly in Gentoo GNU/Linux

yes

fw bisqwit is terry

bisqwit a jew

true
that market share though

>9 out of 10 people use a botnet

The sane or the insane one?

Is Terry his evil twin?

build your botnet and take those suckers' money quick, user

Wow! GNU/Linux community 2 times bigger than 5 years ago.

i'm pumped for linux and oss, but GNU nazi should probably die

Idris 1.0 has been released, Hasklel confirmed dead: idris-lang.org/idris-1-0-released/

Maybe if you don't count

GNU/nazi doing masterpieces of software.

meme-lang is dead, long live meme-lang!

is the website written in Idris itself? because it's pretty damn fucking slow

How does one rotate some fragments of a page?

artists are easily memed

there's many way to do that
looks like some countermeasure for newfags
anyway fuck off to

Why do you wear socks while programming?

>C
No one cares

>These “you should switch language” remarks are strangely enough from the backseat drivers of the Internet. Those who can tell us with confidence how to run our project but who don’t actually show us any code.
>This is an usual problem with people participating in discussion over the Internet. I am sure those people mean well, but often they don't put enough effort into assessing the situation and underestimate its complexity before they decide to hit the keyboard. I've myself done it a number of times, but I am working on not doing it.
>Advice for the people who are making all these suggestions and: A good way to see if you're talking out of your ass—unintentionally, of course—is to try to do what you're saying someone should do. Just try and re-write some parts of curl in Rust (you can go with a hip name like rurl). It's a good exercise to learn about the project you're rewriting, the language you're writing it in, and the problem domain. So, at the very least you'll get something out of it, and if your project is successful: even better!

Wtf I love C now!

Goading people into writing useless projects is an abomination.

int sum(int a, int b)
{
if (0 == a) return b;
if (0 == b) return a;

return (1 + (sum(a, b - 1) + sum(a - 1, b)) / 2);
}

If not C you would be dead already.

Does Python have optional arguments when unpacking tuples?

April fools!

>

Just use underscores?
(a, _, c, _, _, f, ) = (1, 2, 3, 4, 5, 6, )

What if I want a default value instead of _?

>backwards comparisons
Into the trash it goes.

You set the default value when creating the tuple, otherwise the number of elements won't be correct so it's more of a packing rather than unpacking issue.

Can you show an example of why this would be done?

>nextiter :: Integer -> Integer -> Integer -- takes in two integers, returns one integer
>nextiter n i | odd n = nextiter (3*n+1) (i+1)
>nextiter n i | even n = nextiter (div n 2) (i+1)
>nextiter 1 i = i -- "return" i when it reaches 1

[CODE]
nextiter n i
| odd n = nextiter (3*n+1) (i+1)
| even n = nextiter (div n 2) (i+1)
| unreachable code you fucktard, n is always either odd or even
[/CODE]

nextiter n i
| odd n = nextiter (3*n+1) (i+1)
| even n = nextiter (div n 2) (i+1)
| unreachable code you fucktard, n is always either odd or even

What's the defacto introductory book on algorithms?

It's really just a curiosity. To better illustrate what I'm talking about, consider this code in Lisp:
CL-USER> (destructuring-bind (a b c &optional (d 'default)) '(1 2 3) (list a b c d))
(1 2 3 DEFAULT)

CLRS

Why would you want "just a curiosity" polluting a language's syntax?

I wouldn't call it pollution. Anyway, that was only one feature of destructuring-bind I was curious about in Python.

Programming noob here. I have a simple question about floating numbers. In this program, we are looking for the square root of a number using Newton-Raphson's method. My question is about the EPSILON number. When the program compares the "guess" number against the "epsilon" number(guess => epsilon), is it measuring number "accuracy", or is it measuring number "quantity". Because I would expect "1.414216" to be a bigger number than ".00001". I know its a stupid question, but it has been bugging me for a while. Thanks in advance.
Program 8.8 Calculating the Square Root of a Number

// Function to calculate the absolute value of a number

#include

float absoluteValue (float x)
{
if ( x < 0 )
x = -x;
return (x);
}

// Function to compute the square root of a number

float squareRoot (float x)
{
const float epsilon = .00001;

float guess = 1.0;

while ( absoluteValue (guess * guess - x) >= epsilon )
guess = ( x / guess + guess ) / 2.0;
return guess;
}
int main (void)
{
printf ("squareRoot (2.0) = %f\n", squareRoot (2.0));

printf ("squareRoot (144.0) = %f\n", squareRoot (144.0));

printf ("squareRoot (17.5) = %f\n", squareRoot (17.5));

return 0;
}


Program 8.8 Output
squareRoot (2.0) = 1.414216

squareRoot (144.0) = 12.000000

squareRoot (17.5) = 4.183300

Long story short: floats are weird.

If you are making an editor of sorts: text editing, image editing, sound editing etc... how do you implement the back and the forward button? Do you keep track of the changes, Like, these pixels went from this to this rgb, or do you keep the state of the whole picture/text/...?

Then, I guess I am not so retarded to get confused by this. I will take by your answer that it is indeed measuring the "accurancy" of the number, instead of the "quantity". Meaning, that a 5 digit number is somehow bigger than a 6 digit number. At least, that is what I got from this program.

>When the program compares the "guess" number against the "epsilon" number(guess => epsilon), is it measuring number "accuracy", or is it measuring number "quantity"

guess is the current guess for the square root
x is the number whose square root you're calculating

epsilon serves as a convergence limit

It compares how close guess*guess is to x and stops when you reach a close enough distance depending on what epsilon is.

Decreasing epsilon will make the algorithm run longer but will give you a more accurate result.

Increasing epsilon will give you a faster algorithm but a less precise result.

Lol.

I'm having a problem in C++. I have a class, and a function that increments (or resets when > than whatever) one of its member variables. I have other functions that read this same variable. The one that increments always has the correct value, the others always read it as 0. I made a test function that just returns it, it returns 0. The incrementing function will cout the correct value. The incrementing function doesn't declare a static or local variable of the same name.

It's functioning as though it's keeping a local copy for each function. Certainly this is not intended behavior. Using gcc 6.3 (MSYS2). Tried a debug build, does the same thing. Can't find any logic error. Haven't looked at generated assembly yet.

Any ideas?

Post code.

Sounds weird. Can you give the code in question? Is declaring stuff as private, public and protected done right? Are you initializing it or not with a value? What about const correctness?

I know these things are part of the syntactic analysis, but who knows.

Oh noice. I understand what you mean. Is that a consistent behaviour with all floating numbers when it comes to comparing?
Is this statement correct?

I have no clue what I'm doing here. If I leave the code like this then it'll let me input five numbers but the last number that gets input won't be counted towards anything. I can move my if statements around and get the fifth number input to at least be checked for high/low but it still won't be added to the sum. Am I even using the right loop for this? So far we've learned for, while, dowhile.

int high, low, sum = 0, i, count, choice;
double avg;
printf("Enter a number: ");
scanf_s("%i", &i);
high = i;
low = i;
for (count = 1; count < 5; count++)
{
if (i > high) {
high = i;
}
if (i < low) {
low = i;
}
sum += i;
printf("Enter a number: ");
scanf_s("%i", &i);
}

Walk through it and you'll get the answer. Help yourself.

doing sepples things

I have walked through it multiple times, I can fix one problem but then something else gets messed up. At this point I'm just shit out of ideas since I'm really new to this and it's class work.

It looks like there could be more compact solution.

Which programmers have biggest dicks?
>c++ and java
>length 17cm
>girth 15cm
>uncut

C is the only language that truly respects your freedoms.

You'll just get the answer here, not understanding.

>cm

ofc cm, not some american retarded "

If i have 2 constructors in c#, one that takes all arguments and one that takes only 2 for example...

private static int count = 0;

static List listOfPhone = new List();

public string Model { get; set; }
public string Manufacturer { get; set; }
public int Price { get; set; }
public string Owner { get; set; }
public Battery Battery { get; set; }
public Display Display { get; set; }

public MobilePhone(string model, string manufacturer, int price, string owner, Battery battery, Display display)
{
count++;
this.Model = model;
this.Manufacturer = manufacturer;
this.Price = price;
this.Owner = owner;
this.Battery = battery;
this.Display = display;

}

public MobilePhone(string model, int price)
: this(model, null, price, null, null, null)
{
}

...how do you write a Method that prints all data entered.

My current method

public void DisplayInfo()
{
Console.WriteLine("Model: " + this.Model);
Console.WriteLine("Manufacturer " + this.Manufacturer);
Console.WriteLine("Price " + this.Price);
Console.WriteLine("Owner " + this.Owner);
Console.WriteLine("Baterry model: " + this.Battery.Model);
Console.WriteLine("Display size: " + this.Display.Size + "\nDisplay colors: " + this.Display.Colors);
}

When i create an instance that has only 2 arguments entered method throws
System.NullReferenceException: 'Object reference not set to an instance of an object.'

you put "enter a number" at the end of the loop... think about it, specially when count = 4.
perhaps you are misunderstanding the condition...

Is there a consensus on "modern" C++ (11,14,17) vs "classic" C++?
Should I try to learn the new features?

Well, value. You can use a rel error if you want a unitless error instead: abs((g*g-x)/x), for example

Maybe if you don't count Lisp

It doesn't matter where I move it, I get an error one way or another. If I move the enter a number to the top of the loop then yes it'll do the checks for the high/low but the sum will still get fucked up.

192mm here long

better question would be: why my constructor that has null value for instance of an another class doesn't make that instance with null values?

"Classic" C++ is a nightmare, the new features are well worth learning to make your life easier. unique_ptr, lambdas and move semantics are essential.

Instead of a conditional loop with i != -1 as the condition, you need an unconditional loop with a conditional break.

You're setting Display to null, are you surprised it's throwing a null reference exception when you try to access Display.Size?

I just started learning, shouldn't that send all properties in Display to null?

If not, how would i solve printing that in a method? I mean, some phones would have Display info and some wouldn't

Practicing some JS/SQL, how would I add multiple rows in a table in a DB while adding just 1 row in another table? Per one button click. Right now it just adds 1 row to each table, but I need 3 rows inserted in one of the tables

yes.
classic is garbage compared to modern C++, try to forget everything you know about it.

>I just started learning, shouldn't that send all properties in Display to null?

No

#include
int main(){
int high, low, sum = 0, i, count, choice;
double avg;
int first = 1;
for (count = 1; count high) {
high = i;
}
if (i < low) {
low = i;
}
sum += i;
}
printf("low = %d, high = %d\n", low, high);
}

it's ugly, but it works. I think there are better ways to do it, though