/dpt/ - Daily Programming Thread

The APL Programming Language Edition

What cool shit are you working on fellow D programmers?

Other urls found in this thread:

docs.oracle.com/javase/tutorial/
cprogramming.com/tutorial/functors-function-objects-in-c .html
twitter.com/NSFWRedditGif

first for c

prev thred

second for Haskell

Ah shit nigga, I completely forgot the previous thread

How come I get the alphabetically first country when the sub-query gives a table ordered by population?

Porting an old copy of Zork written in a non-standard dialect of fortran 77 to gfortran so I can compile it on linux.

My end game is to hook it up to a fortran web framework and serve zork as a microservice. Then I can hook it up to an SMS API and play zork on my phone even when I don't have mobile data.

Pic very much related.

We coming for your jobs

Best IDE for python?

PyCharm

vim or emacs

>Python
>IDE
some people are so out of touch

"no"

What's the deal with this image anyway?

Be a good boy and help mommy with her coding. She'll give you kissies if it compiles~

Can anyone recommend a good book for sql? Not an intro to sql, but intermediate to advanced?

If you are on Linux, get literally any text editor that supports embedded terminal (Gedit/Geany/Kate/pluma etc) .

On windows use PyChard

Look up APL

How do you create a array from an int value in C#?

Say if the the int was 1234 the array would be {1,2,3,4}

Is this book outdated in 2016?
I have a pretty good knowledge in C++ and would like to make a transmission to C, is this book a good choice or more like a meme book?

Thanks

>how do i google

Think about how you can cleanly extract a single digit from a number and add it to an array, then extract the next digit until you got all of them. It'll require two math operations.

I mean transition.

>C#
>Think

Someone give me a good documentary to put on in the background while I work

int to string
split string

t. goggle

Then he would have an array of chars

do it the math way you fucking retard

So in other words, you want to create an array of digits?

Find out the number of digits
Allocate an array
Extract each digit from the number
Set the values accordingly.

To get the least significant digit in a number, just calculate the number modulo 10. For example, 2016 % 10 is 6. To chop off that 6, calculate an integer division by 10. Using the same example as before, 2016 / 10 is 201, using integer division.

Too many memory allocations.

You asked this is in the stupid questions thread too, you seriously don't know how to do that or even Google it for that matter? Do you seriously want me to make you a program that does that?

modulo 10 returns the last digit, so
1234 % 10 = 4
1234 / 10 = 123.4
123.4 % 10 = 3.0
and so on

>the math way

kill yourself

I guess he needs a loop stopper too.
number A
module 10 of A into array
A=A/10
if A>1, continue, otherwise stop

if A>=1, fixed that for myself

(define (cons a b) (lambda (n) (cond (n a) (#t b))))
(define (car cell) (cell #t))
(define (cdr cell) (cell #f))

Was it hard to put A>0? -_-

PyCharm feels a bit cluttered, or is that just me not being used to full suites?

if I converted the int to string conversion to the lamda calculus would that be math enough for you?

well, yeah lmao.. same thing tho

no that would be absolutely disgusting

daily reminder that coding isn't the same as programming

What I there's a leading zero?

why?

010 > 0

the non-retarded solution is obviously not converting it to a string like a fucking normie

Should I get into compsci even if I won't be getting into Uni until a year from now? I have an AA with most experience in front end web stuff and the adobe suite. I know it may come off as difficult compared to what I've been doing.. but I'm hungry for the payoff and what you're able to achieve

The word you are looking for is scripting.

goddamn man give a reason why it's retarded It's annoying that I have to keep asking the question.

Also, it would probably be best to calculate an absolute value, now that I think about it. An int in C# is signed, and a negative number modulo a positive number is negative in C#.

Programming is a proper subset of coding
Scripting is a proper subset of programming

it's extremely inefficient, you should only use strings when dealing with actual text, not when you're clearly just dealing with ints, use ints not fucking strings

01234

eventually you'd get down to 01 and the 1 would get cut off and 0 isn't greater than zero so it wouldn't add zero to the array

>retard
>calls other people "fucking retard"

>=1 vs >0 doesn't change anything and the array gets initialized with zeroes anyway

so it's a speed thing instead of a math thing?

it's a math thing too, conceptually what you're doing with the string it's like you're just writing the number on a piece of paper and chopping it up, you're not defining the simplest, most elegant solution using basic arithmetic operations

>mono has an interactive REPL
nice

I imagine this is what the zodiac killer codes in.

I can't imagine what a non-interactive REPL would be like.

i honestly don't understand why not using basic arithmetic operations isn't elegant. It's faster since computers have a memory bottleneck instead of an operation bottleneck. But with the paper example, it seems like it would be easier to cut apart the number graphically instead of doing a bunch of math by hand.

>computers have a memory bottleneck instead of an operation bottleneck
that's one major reason why doing it with strings is far slower you dick

best way to learn regular expressions?

by interactive in this case I meant it even has a drop down menu.
the Go REPL, gore, sucks in comparison to this...

I already said that it was faster on a computer but I was asking why it's less elegant in general.

you're just taking 1234 and turning it into [1, 2, 3, 4], you're not saying the actual behind the scenes mathematical solution, you're just describing an inefficient way to do it with the strings, and you leave the implementation to the built in string functions, you're not actually solving it yourself

It would be quicker in the paper example to use the brain version of string operations. Similarly, If the computer was designed to process symbols instead of numbers, it would be quicker to use string operations instead of arithmetic operations. Neither is inherently more elegant in general.

You don't have to use the string functions in the same way you don't have to use the built-in arithmetic operations. You can implement both of them or not; it's not relevant.

and it just crashed, lel
csharp> System.Console.
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Mono.Terminal.LineEditor+CompletionState.DrawSelection () in :0
at Mono.Terminal.LineEditor.SaveExcursion (System.Action code) in :0
at Mono.Terminal.LineEditor+CompletionState.SelectNext () in :0
at Mono.Terminal.LineEditor.CmdDown () in :0
at Mono.Terminal.LineEditor.EditLoop () in :0
at Mono.Terminal.LineEditor.Edit (System.String prompt, System.String initial) in :0
at Mono.CSharpShell.GetLine (Boolean primary) in :0
at Mono.CSharpShell.ReadEvalPrintLoopWith (Mono.ReadLiner readline) in :0
at Mono.CSharpShell.ReadEvalPrintLoop () in :0
at Mono.CSharpShell.Run (System.String[] startup_files) in :0
at Mono.Driver.Main (System.String[] args) in :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.IndexOutOfRangeException: Index was outside the bounds of the array.

when you do math in non-burger schools, the teacher is interested in the solution, not the answer

it is not interesting to say that the 1234 turned into an array is [1, 2, 3, 4]

what's interesting is how you would take ANY number n and turn it into an array

you would have to do it "the math way" with modulo etc, it wouldn't be an acceptable solution to say to write it on a piece of paper and cut it into pieces

>non-burger schools
Nah, even here in burgerland, we do require you to show your fucking work.

I know this is asked a lot but I looked through last thread and couldn't find it. How do I into programming and what language to start with. I see a lot of people using C around here but I'm still skeptical. I'm not afraid to spend hours reading through pdfs and looking at forum posts to figure problems out but I don't know which language to learn with. Thanks.

yeah i was (half-) joking

In all seriousness though, the decline in standards as a result of Common Core is rather concerning. I'm among the last to have been able to get calculus in high school.

people will recommend all sorts of different languages. i suggest to start with java. but whichever language you pick, stay the hell away from python and haskell.

docs.oracle.com/javase/tutorial/

You guys are fucking retards

Why not python?

If you know C++ then you don't need to learn C because C is just C++ with bloat.

>C is just C++ with bloat

it's not great for learning, it's sloppy and has a lot of python-specific nonstandard features vs other C-derived languages. a strongly typed language like java helps you learn types and java has great OOP support (python has OOP too but most people ignore it because of how bad it is)

I am trying to learn c# for unity. Can you tell me a site with tutorials that I can start with?

...

might know better, at least for unity-specific stuff

Why does C return random values when I forget a return at the end of a function.
Better yet, what compile flags am I missing to warn me if this?

Thanks for the heads up
Thanks you I'll probably end up playing with C++ and see how I like that. Then move along to different languages.

What are you talking about, that shouldn't even compile.

gcc -x c++ prog.c

I use GCC.

>Java
Why would you suggest that unironically?

>but whichever language you pick, stay the hell away from python and haskell.
Haskell is a great language if you are actually interested about CS.

>Haskell is a great language
laughinggirls.jpg

Hey Sup Forums
Suppose you on occasion pass an object into a vector. Is it possible to force it to use a functor for the comparisons used when calling .get or .equals?

in c++, it only gives a warning by default. if you use -Werror, it wont compile

iirc the stdc calling convention returns values via the stack, so when you dont do "return x;", you just get some uninitialized data, or some junk from a previous write

This is for java, if it wasnt obvious

Need to write the Show instance and take a list of random numbers or a seed, but still
ghci> (nextGeneration . population) "aaBBCcDD AaBbccDd" 2
[[('a','a'),('B','b'),('C','c'),('D','d')],[('a','a'),('B','b'),('C','c'),('D','d')]]

you mean the object is an element of the vector?

A functor is a mathematical concept quite removed from CS. Assuming you mean function, yeah of course you could do something that determine whether the objects are the same type or have similar type fields

hey, I know you guys aren't my personal teachers here but I'm in a serious bind and google can be a complete fuck when it comes to some of this shit

C# assessment requires I show details after clicking on something I have in my listbox, I already have the parallel array set up and all the data it's getting from a .txt file.

I just don't know the syntax straight up on how to show the details in a label or something

I know listView would be the obvious choice but this task only wants us using listBox

>A functor is a mathematical concept quite removed from CS
what?
cprogramming.com/tutorial/functors-function-objects-in-c .html

>Using C++
>well using a functor is basically using a C++ object and accessing it via a pointer
ok so basically just using C but worse, because it supports overloading? So yeah, pretty removed from real CS other than through autists trying to make an infeasible programming style make sense

nice meme

yeah keep the rationalizations coming.

Is there a windows command line i can use to return the first characters of a text file?

learn malloc and sub function array accessing you damn barbarian

much better version
float rootbeer[10], things[10][5], value=2.2;


scanf("%f", &rootbeer); is invalid since you cant change the address of an address
rootbeer = value; is invalid since rootbeer is a constant
printf("%f", rootbeer); is valid? since its an address, and, and addresses, being hexadecimal, can be cast into doubles
things[5] = rootbeer; is valid?, because rootbeer == rootbeer[0], and things[5] == things[5][0]?


I just started, you fucking nigger.