dpt - Daily Programming Thread

What are you working on, Jow Forums?

Old thread:

Attached: 1200px-Commutative_diagram_for_morphism.svg.png (1200x1200, 29K)

Other urls found in this thread:

xarql.com
en.wikipedia.org/wiki/Huffman_coding
pointwise.com/glyph2/files/Glyph/cxx/GlyphApplication-cxx.html#pw.Application.MeshUnits
en.wikipedia.org/wiki/Category_theory
en.wikipedia.org/wiki/Commutative_diagram
twitter.com/SFWRedditImages

This : xarql.com

Working on a tagging system for my files in curses.
Very slow, but steady progress... Here's a title bar!
And don't worry! I'll make it such that you can customize the colors.

Attached: Screen Shot 2018-08-13 at 9.18.03 PM.png (1216x592, 26K)

\dpt\
are we in windows or what? disgusting

I want to write a program who, given an appropriate int, prints out the corresponding character string while adding spaces between letters.

For example, get the number "7097103103111116", divide it into "70", "97", "103", etc etc, then print out the letters. In this case the output should be "F a g g o t"

do your own homework.

I'm doing it for fun actually.

for one thing you won't be able to tell the difference between '1' and '11'
anyways
en.wikipedia.org/wiki/Huffman_coding

hold on

How do you know whether to parse as 70, 97, 103? Why not 70, 97, 10, 3?

Because character strings are represented by numbers between around 30 and around 130. If the number starts with a "1", then it's bound to have three numerals.

Can I compare a function pointer to a string in C?

For example, a function pointer is passed to a function, and I want to check if the function pointed to is called "my_func"

A function pointer is just an address.

I haven't come across any scenario any situation where you'd need to do that, but if you absolutely need to, I would recommend the following
Create a structure that contains both a function pointer and a string representing the name of the function.
You could have a collection of pointers to these structs.
Once you go through a function, create this struct and place it in the collection somehow.


Out of morbid curiosity, why do you want to compare pointers to strings?

public void DoesYourHomework(int StarterInt){

TextView TextViewOne;
TextViewOne = (TextView) findViewById(R.id.OnlyTextView);
double[] Output = new double[9];

int IntLength = String.valueOf(StarterInt).length();
int LoopCounter;
double ModCounter = Math.pow(10, IntLength);

for (LoopCounter = 0; LoopCounter < (IntLength+1); LoopCounter++) {

Output[LoopCounter] = Math.floor(StarterInt/ModCounter);
ModCounter = ModCounter/10;

}
TextViewOne.setText(" " + Output[0] +" " + Output[1] +" " +Output[2] +" " + Output[3]+ " " + Output[4] +" " + Output[5] +" " +Output[6] +" " + Output[7]+" " + Output[8]);

}

anyone want to hear the track I composed for my game?

How would you parse 7112 then? 7, 112 or 71, 12?

Such a number couldn't be parsed, but I'm only interested in numbers which can be parsed.


Thank you very much.

actually I misunderstood what you wanted, that code will buggily produce just the individual digits spaced, and not try anything with turning it into a word.

In Python when using the range() function as range(x, y) where x and y are unordered what are the best practices in order to ensure that it's range(lowernumber, highernumber)? I used an if/else statement but I feel like there's a better way as otherwise in a bigger program it would involve way too much copying and pasting.

Would it be better to put the two variables in a list and then sort them and then have it like range(list_variable[0], list_variable[1])? Is there a better way I haven't thought of yet? Sorry if this is a stupid question but I couldn't find much on this specific instance on Google

I might have just figured out my own question

The best way is range(min(x, y), max(x,y)) isn't it?

well its really elegant in any case.

thats about 10 times more efficient than creating and sorting a list, yes

Working with tcl for a Pointwise script I'm making...
God fucking kill me this is the worst language

# Changes units to METERS
proc convert_default_units_to_meters {} {
array set unit_arr {
{in} 0
{ft} 1
{m} 2
{cm} 3
}
set meter_enum [lindex [array get unit_arr {m}] 1]

# Can this line be put into two-three lines?
pw::Application setCAESolverAttribute MeshUnits meter_enum
}

puts [convert_default_units_to_meters]


pointwise.com/glyph2/files/Glyph/cxx/GlyphApplication-cxx.html#pw.Application.MeshUnits

Are there multi-line commands in tcl?

Looking for work and everything is data science/analytics. Any good up to date courses for getting up to speed with the meme?

Why is this image true?
How is g . f equivalent to f^2 + g^2? That doesn't make any fucking sense. First of all let's assume we're treating composition as comparable to multiplication and by extension treating numeric exponentiation as comparable to self-composition. Then f^2 = f . f and g^2 = g . g. So how exactly the fuck are you supposed to interpret the +? No excuse me sir, fuck you there's no such fucking thing. There are two possible meanings I can imagine for +. First is if we consider it as meaning Church summation. But that don't make no fucking sense, because first of all what if not all the functions we're working with are Church numerals, and secondly, even if they are, what's the point of using the composition symbol and the addition symbol in the same diagram when they mean the same fucking goddamn thing. Second meaning is the same kind of thing as adding unlike units, you just consider them orthogonal and then the result is that the sum can't be broken down any farther and acts as a kind of tuple. Well fine. But then we're no longer strictly talking about functions, we have to generalize our entire fucking arithmetic to include TUPLES of functions. Though to be fair, that does offer some useful properties, for example multiplication distributes over addition so multiplying a function left of a sum of functions would be equivalent to mapping the function over that tuple, but multiplication when treated as function composition fails to be commutative so that means multiplying it on the right of the sum, i.e. (g + ...)(f), would instead map \h.(h.f) over the sum, rather than mapping f over it. But even then, your image is still fucking retarded. How the fuck is g.f equivalent to (f.f) + (g.g)? You're taking a function and saying it's the same thing as a binary tuple of functions. That's retarded as fuck. Fuck you go fuck your mother.

Wow, I'm fucking stupid, I misremembered the Pythagorean theorem. But still, your picture is dumb, first of all what even is a square fucking root of a function, I mean what, is that where you only half-evaluate it? First of all that's dumb, that's not even always necessary well defined, and secondly, how the fuck you gonna tell me the square root of a binary tuple of functions is a single function, bitch it ain't.

Are you just pretending to be retarded? Sometimes I can't tell.

Tell me a single thing you find objectionable about my line of questioning. Other than the thing I just corrected.
Is that picture not of a right triangle with the two legs labeled f and g and the hypotenuse labeled g.f?
It is, and this clearly is meant to imply that g.f = (f^2 + g^2)^0.5. Which is plainly fucking stupid.

Dude, the arrows means that f is a function that receives input with type X and returns type Y. f and g being functions you have g . f to go from X to Z.
It's the simplest combinator operator.

If that were all there is to it, they wouldn't have made a point of expressing this relationship as a right triangle. It's clearly trying to indicate that in such a relationship between functions, the triangle IS indeed a RIGHT triangle, and COMPOSING the functions results in a function equal to the HYPOTENUSE of that triangle.
WHICH IS PLAINLY RETARDED.

that is not a picture of a right triangle, please consider growing a few brain cells

Please consider growing a few eye cells.
That is plainly a right triangle.

states = {}

for x in range(32, 126):

char_str = str(x)
nested_state = states

for i, digit in enumerate(char_str):
if digit not in nested_state:
nested_state[digit] = {}

if i+1 != len(char_str):
nested_state = nested_state[digit]

nested_state[digit] = unichr(x)

def dothething(states, numbers):
# '7097103103111116'
cur_state = states
for digit in numbers:
cur_state = cur_state[digit]
if isinstance(cur_state, basestring):
print cur_state,
cur_state = states


try:
dothething(states, '7097103103111116')
except:
print "Invalid"

the corners aren't even connected, the lines are arrows, and any other graphical arrangement would make less sense for what is being conveyed.

>the corners aren't even connected, the lines are arrows,
Still a right triangle.
>and any other graphical arrangement would make less sense for what is being conveyed.
"What is being conveyed" being, of course, that g.f = (f^2 + g^2)^(1/2)?

Ok, too obvious.

You're the type of person that buys and supports Bcash.

Nice.

Anybody know why this won't work?
$OS = @(
"Windows 10 Enterprise"
"Windows 8.1 Enterprise"
"Mac OS X"
)

$data = Get-ADComputer -Filter {Enabled -eq $true -and logonCount -eq 0 -and -not $OS.contains("Operatingsystem")} -Properties *


And I get:
Get-ADComputer : Property: 'contains' not found in object of type: 'System.Object[]'.
At line:7 char:9
+ $data = Get-ADComputer -Filter {Enabled -eq $true -and logonCount -eq 0 -and -no ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ADComputer], ArgumentException
+ FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.ArgumentException,Microsoft.ActiveDirectory.Management.Commands.GetADComputer

>its an LLVM occasionally bugs out with obscure errors and marathon

i started on a small tagging system the other day in python when i got too frustrated with another. a few hours in i thought i would probably need to redo the whole thing with relational dbs for the whole things not to completely suck with a fair amount of entries. how's your design?

Hello Jow Forums, I'm finally learning how to program and it's very exciting, but my book mentioned something about style and now I'm wondering whether I should be using tabs or spaces? Which is the correct Jow Forums way? Also what about curly braces?

my script to open dpt took me to the old thread because of this.

it literally doesn't matter.
don't fall for bullshit programmer bike-shedding.
use what you want.

i'm glad you averted that train wreck but i still don't understand what you meant by 'too much copying and pasting'.

#include
#include
int main() {
int c = 0;
for (int d = 0; d != EOF; d = getchar()) {
if (isdigit(d) && (c = 10*c + d - '0') > '~') {
printf("%c ", c/10);
c = d - '0';
}
}
if (isprint(c)) printf("%c ", c);
puts("");
return 0;
}

ok I wont worry about it then

It doesn't matter as long as you are consistent.

If you do use tabs be sure to only use them for indenting, not alignment.

def foo():
\t call_some_method(with, a, lot,
\t of, params)


On that second line you should only hit tab once, then the rest should be spaces.

Do I have to move to the US when I graduate to make any money?

every editor can convert one to the other and even if it didn't you could accomplish as much with a regex and your clp of choice. when you join an existing project you'll want to adopt their standards. just do be the guy that does this.

1/10

Is it still useful to become a native mobile dev?

I feel like everyone is using js shit nowadays.

Strongly-typed languages make the best languages. Prove me wrong. Protip: you cant ;)

Damn right I can't

Attached: 1511203581001.jpg (850x1144, 118K)

type system where you just write free functions and then your entire program is composed automatically from start type to end type using a graph of type conversions

Attached: .jpg (741x915, 334K)

show me a strongly typed language better than c


(which is not strongly typed)

How would your type system handle a case like this?
A :: *
f :: A -> A
g :: A -> A
h :: A -> A

en.wikipedia.org/wiki/Category_theory
There is no significance to the diagram being a right triangle. The line could have been drawn squiggly and round instead.

>There is no significance to the diagram being a right triangle.
Well then it shouldn't have been a goddamn right triangle then.
Geometry is not a thing to be casually invoked.

C#

It's a way of laying out a diagram you retard. The arrows aren't even fucking connected.

value dependent types +
what if you weren't allowed to have two functions with the same type signature?

A -> A shouldn't make sense in this programming language

and dot, presumably

>It's a way of laying out a diagram you retard.
Yeah, and it's a BAD way of doing so, if you don't INTEND to invoke the geometric properties of a right triangle.
>The arrows aren't even fucking connected.
Doesn't matter.

>Yeah, and it's a BAD way of doing so
show me your version

what is context

Not to mention they're fucking arrows and not lines. Plus this is a category, implicitly there's also an arrow X to X, Y to Y and Z to Z

And tessellation is a reason to use right triangles. If you have some extra objects you can compose them and you can compose the compositions and lay it out like tiling.

>three people cant stand in a right triangle, or they are invoking the sacred geometry

//curry pair
[](int i) { return [i](int j) { return std::make_pair(i, j); };}

Attached: Touhous 368 (QD).gif (758x696, 102K)

this is correct as long as f or g are functions that don't change the variable, like *1 or :1

Well, I mean, yes, actually. Because if three people stand in a right triangle, then there are invisible hypothetical line segments connecting every distinct pair of them, such that the longest is the square root of the sum of the squares of the other two. It's not as if this information is likely to be significant in any way, but it is nonetheless true.
So, in the same way, if a diagram contains a right triangle, and the sides are identified with expressions, the expression identifying the longest side should be the square root of the sum of the squares of the other two expressions.
So? Equilateral and isosceles triangles also tessellate. Even scalene triangles tessellate. Whether acute or obtuse. So why specifically a right triangle? It could only have been due to its specific properties.
>Not to mention they're fucking arrows and not lines.
No one seems to be grasping the fact that this doesn't actually make the figure not a triangle.
>Plus this is a category, implicitly there's also an arrow X to X, Y to Y and Z to Z
Oh yeah sure. Implicitly. Uh huh.
a shit such as you're waifu

>Currying
Why would you ever do this?

You're just being a retard, admit it. Even if it were, what makes you think it would be Euclidean huh?
en.wikipedia.org/wiki/Commutative_diagram

More like why would you ever use a language that doesn't do it automatically as an inherent part of the evaluation strategy, which, as a direct consequence, is also lazy?

applicative functor

Plus why the fuck do you think it's the length?
None of your complaint makes any sense.

More like, why would you ever use a language that even has the concept of currying?
Just fucking let your functions take more than one parameter. It's more efficient.

What is this academic masturbation? And explain why it isn't 100% useless

simpler language, simpler type system

An applicative functor is a pointed functor that can lift multi argument functions

>Even if it were,
Even if it were what? A right triangle? Because if you deny that it is, you must be blind.
>what makes you think it would be Euclidean huh?
Occam's razor. Why would it be anything but Euclidean? Do you see shading in the background? Looks pretty uniformly solid white to me.
>Plus why the fuck do you think it's the length?
They're arithmetic expressions next to line segments. By convention, such expressions indicate length, where there's reason to suspect geometry is concerned at all. And there is just such a reason, in the fact that specifically a right triangle was chosen.

>arithmetic expressions
Which arithmetic expression?

>provability is useless

applicatives are very useful

>f
>g
>g.f
the arithmetic here is A) in the composition operator and B) implied in the use of the italic f and g because those symbols are usually used to indicate functions

Correct

For aiding academic masturbation?

>Correct
0/10

>arithmetic
You strike me as someone who has never seen mathematics beyond the level of a 12 year old (literally primary school level) yet feels fit to say anything he doesn't immediately understand at first sight must be an error

it's funny that there are anti-intellectual programmers

you seem to be implying that function composition is not part of an arithmetic of functions

>Correct
You can't honestly believe this.
Provability has a very obvious practical use outside academics, in that wherever it can be automated, programming becomes merely the task of writing programs, and the task of testing programs is obsoleted entirely.

you seem to be implying you can change the context of words every post but compose the whole chain of posts

Attached: 15066f65146136.jpg (680x395, 37K)

you seem to be implying there's been any change of context from the beginning of this conversation

Except that's practically impossible and only restricts you unnecessarily when attempted.
See: Rust

there are formally proven C compilers

i'm surprised you didn't say
>why do any of the previous posts matter at all context is totally unimportant also you'll notice my posts were rectangular therefore ...

Ok?

so it may be practically impossible for YOU but actually its not practically impossible and you're an idiot