/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

cse.chalmers.se/~simonhu/papers/cubicaltt.pdf
twitter.com/SFWRedditVideos

Why do so few programming languages (even Coq and Agda) support the Theory of Homotopy Types (THoT)?

I'm having problems with PHP 7.2.

Can you help me

The problem is in this code:


if count($this->getAttribute($this->getAttribute((isset($context["config"]) ? $context["config"] : null), "mod"), "dashboard_links"))) {

In this version, count () null have a error. Look:

count(): Parameter must be an array or an object that implements Countable.

What I can do to fix that?

Exams over, started writing CHIP-8 emulator. Read the specs and shit, shill can't decide on toolchain:
language: C99 or javascipt/typescript
display: terminal, SDL/SFML or HTML5+canvas (implying JS)?
also Wikipedia lists some Pseudo C representation of assembly commands, would it be worth to also implement pseudo-c compiler on top?

How about this:
$attr = $this->getAttribute(...);
if ($attr != null && count($attr) > 0) {
// ...
}

Because the people who are interested in it are the same people who are interested in animu, and we don't want them around.

>why don't more programming languages support theoretical homo stuff
You need more Javascript in your life, son.

It's too recent.
Coq has been developed since the eighties, the concept of univalence has been invented in 2006, and the reference HoTT book was written in 2012.
Moreover, there is no clear way to cleanly implement the univalence axiom, even though cubical type theory intends to solve everything, but it is even more recent (2016 iirc) cse.chalmers.se/~simonhu/papers/cubicaltt.pdf

If you want anyone to ever see it in action, go for typescript+HTML5. If you only care about getting it done, use whatever you tickles your fancy.

>cubical type theory
The memes simply write themselves.

>if count($this->getAttribute($this->getAttribute((isset($context["config"]) ? $context["config"] : null), "mod"), "dashboard_links"))) {
PHPlets will actually defend this

>no one wants to download anything anymore
speak for yourself, josh.

Our dear lispcuck - making fun of academic wankery?
What sort of loopy land have I entered?

I'm mainly interested in quotients
data a : Set where
+_ : ℕ → a
-_ : ℕ → a
±0 : +0 = -0

>invented
>discovered
FTFY

that "a" should be a "Z"

>making fun of academic wankery?
It's just low-caliber stuff. Real computer scientists have moved on to postmodern ambivalent hyperdimensional quasi-dynamic type theory.

Explain this shit to a retard newbie because I do not understand it at all:
Haskell is a pure functional programming language, and so functions never have any side effects -- their only effect on the program as a whole is through their return value, though they might hide some extra shit in that return value with monads.
Functions in haskell, even non-monadic functions, can throw errors and exceptions.
Throwing an errors or exception is a side effect.

Does this mean the language actually does have a way to cause side effects without monads and it's just "heavily discouraged"? Does the compiler have a special case that only allows errors to cause side effects, and nothing else? Or what the fuck is going on here?

>postmodern
pandora's box and a politics-oriented trojan
fantastic!

"if you use side effects you lose" - (((Simon Peyton Jones)))

>Throwing an errors or exception is a side effect.
Normal I/O is also a side effect. Hasklel handles side-effects essentially by inversion of control, so that the side-effects happen outside of the Hasklel universe.

Haskell cannot inherently be pure because it has I/O.

>unironically learning an academic autism language

my script stops working after I wake up pc
any idea why?
#!/bin/bash

last=""

while true
do
if [ "`xsel`" != "$last" ] # execute only if content changed
then
if xsel | grep "youtube.com/watch" # if clipboard contains youtube link
then
if `zenity --text "Proceed with download?" --question`
then
(clp=`xsel`
ytdl `xsel`
if [ "$?" == "0" ]
then
zenity --text "Download successful\n$clp" --notification
else
zenity --text "Download Failed\n$clp" --notification
fi) &
fi
fi
fi

last=`xsel`

sleep 0.2
done

You program with pure functions, then Peyton's Devil, who lives outside the system, calls into them with input and collects their output.

Exceptions are sort of but not really a side effect, it's more like a shitty inconvenient extra value, like
x :: Int
x = (throw an exception)

Kind of like null. Null isn't really a side effect, but it sucks anyway.
You can think of the way Haskell does effects as being similar to an AST:
data IO a =
PutChar (Char, IO a) -- putChar(char, nextAction)
| GetChar (Char -> IO a) -- getChar(\char -> nextAction)
| Return (a) -- return (x :: a)

You can combine these ASTs to produce a bigger AST, but they're still ASTs (which are just pure values).
Monad is one way of combining them:
do x

>Have brother living in SEA
>He caught a small python trying to make a nest in his house
>His neighbor told him to cook it
>Ask me for a way to cook it
>Send picture
>He was not happy

Errors aren't side effects. They're the computation failing. That's like saying infinite loops are side effects.

And I won't let Haskell say its pure. Monadic IO enforces a sequence through pure means technically I suppose, but DO notation is indistinguishable from an imperative language. So in effect Haskell invented a new way to compile imperative languages to purish ones. Also the IO command sequence formed is incrementally consumed, and IO reads enforce synchronization.

maybe someone is better in number theories than me. lets say I have a 3d grid that has undefined size. how can I calculate an isomorphic index (= 1 number) from the x, y and z position of every gridpoint?
maybe x*prime + y*prime + z*prime or along those lines?

Cantor's pairing function.

more progress on the opengl tutorials. multiple lights, specular and diffuse maps, using a model loader lib

This has nothing to do with number theory. You can't do it with unbounded 3D grids each axis already covers every possible index value.

okay what's the deal with evil-mode ? Is it really _that_ much better ?

I actually like this
>Peyton's Devil
bonus points

What do you use to make those video screencaps?

Where should an electronic engineer look for a project partner with a strong grasp on AI? Obviously I won't find them here, any places I should check out?

obs my dude

You're right that it's not number theory. It's set theory, and you're wrong that it's impossible. The cardinality of N is the same as N x N. Guess you fell asleep in discrete math.

One way to understand is to write your own sort of "effect" type.
You realise that you really are just dealing with pure values, including functions on pure values (themselves pure).

Monad is the particular way of combining these types of values (do notation), but you can have other stuff. For simple stuff, even just monoid:

data Action = PS String
andThen :: Action -> Action -> Action
(PS x) `andThen` (PS y) = PS (x ++ "\n" ++ y)
infixl `andThen`

runAction :: Action -> IO ()
runAction (PS s) = putStrLn s

main :: IO ()
main = runAction $
PS "hello" `andThen`
PS "how" `andThen`
PS "are" `andThen`
PS "you?"

Of course with this example, you can't create procedure-like things that "return" values.
All it represents is a string to be printed (in fact it is literally just a string).

If I understand the question correctly then he wants to assign a number to each point with no collissions. One way would be unary encoding distance from origin (4, 3, 1 would then be 11112223). Did I misunderstand the question?

No. You're right and I'm just a retard.

(x + y + 1)(x + y - 2)/2 + y is how you encode it. Repeat the encoding for your xy index and z for 3d coordinates.

Fuck I mean:
(x + y + 1)(x + y)/2 + y

a bijective mapping of ZxZxZ -> Z sounds like number theory to me

this guy beat you to it

ahh, it's pretty obvious when considering a similar approach to the proof of countability of rationals.

The other way is the way he mentioned, 2**x * 3**y works too, but it's not as nice to un-encode. Not to mention exponents taking log n time to evaluate and the growth of your encoding index being O(2^d), d for distance. When I took math they did the 2 and 3 thing to prove countability of rationals to us. It's simpler to think about. Cantor's came in during analysis 2.

There's many ways to skin a cat though. Cantor's pairing function has been proven to the the simplest O(d^2) strategy.

Couldn't you just take some efficient arbitrary precision arithmetic encoding, use it to store two numbers side by side in memory and then reinterpret the resulting bytes as an index?

Lel

I'm going to assume you mean something like this:
x = a1 a2 a3 a4 ....
y = b1 b2 b3 b4 ....

Store it as:
... a4 a3 a2 a1 b1 b2 b3 ...

Can't do 3D. You now have to seek an end of the array.

I mean there are obviously ways to store arbitrary precision numbers in memory, so storing three of them and reinterpreting their bytes as indices should be possible.

as an index*

Suppose I have 2 points:
(0xF, 0xFF, 0xFFF)
(0xFFF, 0xFF, 0xF)
How are you going to distinguish between them?

They're arbitrarily long too.

Whom'st'dve you where the integer extrapolates long?

because
>undefined size

encode length of the numbers that hold the length of the actual number. 0 = break. 1 = amount of bits the number has:
111...1101111... 110111...10|x_length...y_length....z_length|x...y...z...

Either you can't read, or you think that arbitrary precision arithmetic doesn't exist... Here's a simple scheme off the top of my head: encode your numbers in base 255, reserving 0 as a terminator.

An even dumber and yet more blatantly obvious scheme (xxxx, yyyy, zzzz)

That's a retarded way to do it. At least use pascal strings, which would be a reasonable way to implement arbitrary arithmetic.

Less than 50% efficiency. You have some serious not invented here syndrome. It's obvious that unlike you I don't think in stupid user.

What's obvious is that you're so fucking dumb that you couldn't figure out how three arbitrary precision numbers can be stored consecutively without being list, and needed me to spell it out for you.

being lost*

Ahhh. That's your problem. Scroll up and see what the topic was dumbfuck.

I still don't quite understand std::move()
is std::move() the only way to call any method using the double ampersand overload?
Also what is the disadvantage of using explicit move method in the class such as:
struct Foo{
int * bar;
Foo& move(Foo& in){
if(this != &in){
delete bar;
bar = in.bar;
in.bar = 0;
}
return *this;
}
};

>see what the topic was
The topic was how to get a unique index from 3 numbers of indefinite magnitude. I suggested one easy way to do it, which you were baffled by because:
>Suppose I have 2 points:
>(0xF, 0xFF, 0xFFF)
>(0xFFF, 0xFF, 0xF)
>How are you going to distinguish between them?
Which just goes to public schools spoon-feeding math to retards doesn't imbue them with the ability to think.

goes to show that*
For fuck's sake.

So you did manage to distinguish between them, but your method of doing so (converting base or sprintf) is fucking retarded. Oh boy you proved me wrong.

One thing to note here, you moronic piece of pseud trash, is that your solution is absolutely useless, because if he's dealing with unbounded numbers, he ALREADY has to store them as arbitrary precision numbers, and then pointlessly perform calculations on them.

>but your method of doing so (converting base or sprintf) is fucking retarded
My method of doing so (storing three arbitrary precision numbers consecutively and reinterpreting them as an index) is vastly superior to your method for reasons explained here: The sprintf example was just to help your tiny little mind to see that what you seem to think is impossible is actually trivial.

Jesus Christ, how do people handle the explosion of states when programming an interactive application?

It's like an entire new universe is created whenever you add a button to the program.

>just do division O(log n) times.
Yeah you're so smart user.

P U R I T Y

I've got a class Staff and subclasses Waiter, Manager and Chef.
Waiter and Manager can offer refunds, but obviously chefs can't.
How could I implement this (in Java) efficiently? I.e. without making the same method twice? Would I just make an interface "Refund" and have the two implement it?

Your store three arbitrary precision numbers and reinterpret them as an index. This is the most efficient solution. Any other solution involves doing those steps and then, as a drooling moron like you would suggest, also performing dog-slow arithmetic on them.

purity, decoupling, abstraction, algebra, category theory, monad

>converting to base 255 is free
user you were the one wanting to convert to base 255. It's going to be a fuckton of division.

>how do people handle the explosion of states when programming an interactive application?
You break it down into composable elements.

>you were the one wanting to convert to base 255
I was giving you an example of an easy and relatively compact way it can be done, you drooling fucking monkey, because you were insisting it's impossible. Now, after being exposed as a pseud piece of trash, you're desperately grasping at straws.

What more can I be doing to get an internship? I'm a masters student in CS with a 4.0, have a previous internship at Bell Labs, and multiple side projects. What more can I be doing? Or do I need to sell my soul and start doing webdev to get any attention from companies nowadays.

Can anyone help me out with this Python question?


(PYTHON)Heat wave is when a period of at least five consecutive days is over 25.0 degree Celsius or when at least three days is over 30.0 degree Celsius.

How to find out if there's a heat wave when list of inputs are given?

Print 'yes' when heatwave is found.
Print 'no' when heatwave is not found.

Example1:
INPUT:
23.0
25.1
25.4
25.3
25.2
25.0
27.1
stop

OUTPUT:
Yes

There isn't just one thing. Your cover letter and writing in general need to be rock solid and show yourself off well
You need to show that you're active in terms of personal projects and stuff. Open source experience/contribution is gold dust
How far do you usually get with applications? Immediate rejection or is it somewhere down the process?

I never said it was impossible retard. There's more to things than just what's possible. You can't just fucking cast everything to chars and hope for the best.

Your strategy relies on finding an arbitrary precision arithmetic library that is retarded enough to store the data in an array, or moving the segments of each number into an array, or writing your own retarded one, then manually copying everything in a big array. And then hoping for the best. It's just fucking retarded.

Do your homework.
But then again Sup Forums will probably do it for you.

So I got accepted for a free bootcamp to get into prog and turn myself into a .net pajeet.
Shit includes:
HTML ( DOM), CSS3, semantic markup, Bootstrap (or Materialize), Javascript + Jquery
Control flow, Events, Validator(Bootstrap), Dynamic components, SQL, MVC, ORM (modelling, OOP intro), Layers, IDE, Debugging, Deployment.
8hs a week from the upcoming Monday to mid May.

What am I in for? Any supplementary resource that you guys can recommend?
I really want/need a job ;_;
btw this is in Argentina so I doubt I can help anyone here to get into this course, but if any argie (likely a porteño puto) is interested, check "comunidadit".

Thanks.

Have two variables where one increments when it's over 25 and another (both increment) when it's 30+
Then every time check if either reach 5/3 and if they do set a bool value

I did my homework senpai, though i'm sure it can be done a lot more efficiently. Care to help?

temp_array = []
lus = 0
i = 1
while lus == 0:
temp = input("Wat is de " + str(i) + "de temperatuur? " )
if temp != "stop":
temp_array.append(temp)
i += 1
else:
lus = 1 #stopt de while

temp25 = 0
temp30 = 0
j = 0
vorig = 25.0
for j in range(len(temp_array)):
if float(temp_array[j]) >= 25.0 and float(vorig) >= 25.0:
temp25 += 1
vorig = temp_array[j]
if float(temp_array[j]) >= 30.0:
temp30 += 1
else:
temp25 = 0
temp30 = 0
j += 1
if temp25 >= 5 and temp30 >= 3:
print("hittegolf")
break


if temp25 < 5:
print("geen hittegolf")


The names are in Dutch, hope you Sup Forumsuys will find a way in the mess.

>I never said it was impossible retard
Oh, yeah?
>there are obviously ways to store arbitrary precision numbers in memory
To which you respond with this post (), that clearly demonstrates your bafflement. Look, there's only one person reading your posts: me. And I'm already convinced that you're less than human. It's time for you to stop posting. My method is provably the fastest, because any other method involves the steps of my method as the starting point. I wasn't insisting on any particular encoding strategy; just helping a drooling monkey like you understand that it's possible.

stupid frogposter

But there's no explicit move?

Currently working on web automation for data entry, Seriously why don't more businesses create scripts to do the leg work. My job shouldnt even exist.

I asked you that because I wanted to hear your retarded answer. I was hoping to god you'd respond with pascal strings but you gave me something even more retarded.

I went to the final round with two companies, but as of recent I've just been getting rejected straight up. I went through the first round at Google. My resume is good and was recently revised + reviewed by my professional friends.

I guess what's holding me back is that while I have strong experience in programming languages, my framework knowledge is a lot less. I'm aiming for a backend position, yet a lot of these internships still want Node, React, Angular etc.

Open source projects could be interesting, but my current plan was to do a web based sideproject with some of the latest memeworks.

I technically accepted an offer at UPS for a data analytics position, but I'm going to reneg if I find an actual dev internship.

>I was hoping to god you'd respond with pascal strings
Pascal strings have a limited length, you subhuman monkey, so that's clearly not an infinite precision storage scheme. Your retardation levels are off the charts, and your last post proves that conclusively. This was your last (You).

I don't get how the Linux kernel's linked lists work

struct list_head {
struct list_head *next;
struct list_head *prev;
}
struct my_list {
struct list_head list;
int data;
}


How are you supposed to access the data from this list and add to it.

Alright so my edit may not work since I made it in the quick reply box but you should get the point.

- You don't need a temporary variable for the loop condition, you can just do while True and break when you want to stop the loop.
- Instead of converting to float all the time, you can just convert the temp variable to float when appending to the list of temperatures.
- When you want to iterate over the list of values you can do just "for value in iterable" instead of looping over the range and accessing the elements by index. Furthermore if you insist on indexes the j variable increment in the loop is redundant because the loop will take care of it.

i = 1
while True:
temp = input('What is the {}de temperatuur?'.format(i))
if temp != 'stop':
temperatures.append(float(temp))
i += 1
else:
break

for temperature in temperatures:
if temperature >= 25.0 and vorig >= 25.0:
temp25 += 1
vorig = temperature
if temperature >= 30:
temp30 += 1
else:
temp25 = temp30 = 0

if temp25 >= 5 and temp30 >= 3:
print('hittegolf')
break

if temp < 5:
print('geen hittengolf')

I mean why using
struct Foo{
int * bar;
Foo(); //a constructor to populate bar
Foo(Foo&& in){
if(this != &in){
delete bar;
bar = in.bar;
in.bar = 0;
}
return *this;
}
};
int main(){
Foo a;
Foo b(std::move(a));
return 0;
}

is preferred than
struct Foo{
int * bar;
Foo& move(Foo& in){
if(this != &in){
delete bar;
bar = in.bar;
in.bar = 0;
}
return *this;
}
};
int main(){
Foo a;
Foo b;
b.move(a);
return 0;
}

Then that means user is smarter than you. If you don't like that because alignment issues, you can pad them out with 0s or you could alternatively use say bytes for length and have 255 mean "another segment"

l i t e r a l l y n o f o r m a l s y s t e m

why are academics so useless

No, it only means you're such a fucking retard that I had to give you a simple example of how it can be done, after proposing the optimal solution to the user's problem and listening to you completely failing to understand what arbitrary precision integers are. Definite proof here: and here: Since the only way for you to recover is to continue lying blatantly, we can call it a day.

I'll be a liar if you admit you're dumber than :^)