/dpt/ - Daily Programming Thread

Danish Gnome Edition

What are you working on, Cred Forums?


Previous Thread:

Other urls found in this thread:

cs.ecu.edu/karl/cinnameg/8-2/lin/Misc/get.html
cs.ecu.edu/karl/3675/fall16/Assn/Assn4/deriv.cmg
kodewithklossy.com/
en.wikipedia.org/wiki/Mathematical_object
haskell.org/ghc/
youtube.com/watch?v=zBkNBP00wJE
rastertek.com/tutdx11.html
mysqltutorial.org/mysql-subquery/
boards.Cred
twitter.com/SFWRedditImages

First for C++ iostreams are a complete joke, as well as the rest of the language.

learning C so I'm not a cuck in my robotics class.

>first for old news

What do you mean, "sort of manual but sort of not"? It's all manual, using either linear types or monads to keep it safe.

I mean I would just do the computations in the IO monad, or a restricted version of it

So then you have no safety.

And thus, no purity. Well, I suppose it's technically pure, if you consider the IO monad as describing effects like "segfaults" or "corrupts the kernel" or "does irreversible damage to your hardware".

Like just using peek, poke, malloc, alloca, etc

No memory safety, yeah.
If I want to mess around with memory I'll do it myself.
You could implement reference counting or custom GC and abstract it away.

>you can make it safe by making it slow!
Your best point against linear types is that you don't care about what they fix. Might as well have gone for that in the first place instead of wasting my time.

Look at my beautyfull Vba code /g

...

Working on an extension to make code executable in code tags. Still choosing which language it should execute. I was thinking Scheme, calling it FourScheme, or ForeScheme

uh.. n-no habla espanol

>And thus, no purity
That doesn't follow at all.

RC isn't that slow, and as I said, I'd rather do it manually
If I wanted "True safety (TM) (TM)" I'd be using a dependent language, not some trashy "C with linear types" language. Oh, and your definition of true safety apparently excludes a great deal of programs, including the rm program.

I'm programming a Video/TV Show app, and I want your input Cred Forums on something!

If the user chooses an episode of a tv show, what would the back button do?

A. Go back to TV Show's episode list
B. Go back to the Video Library

So? Which is the most correct?

And that is better than proper format strings how?

>goto's
>comments longer than code
>espanol
-2/10 tbqhwuf

>That doesn't follow at all.
Read the rest of the post.

>If I wanted "True safety (TM) (TM)" I'd be using a dependent language, not some trashy "C with linear types" language.
Where are you getting this from? Where did I say no dependent types?

>Oh, and your definition of true safety apparently excludes a great deal of programs, including the rm program.
rm isn't safe.

Didn't say it was better. Just not as horrible as international user wanted to make out to be. All his other complaints still stand.

It doesn't matter what effects IO does, standard Haskell or safe ghc haskell never peeks inside.

>where did i say no dependent types
You didn't, but then that's not an argument for linear types.
(Which of course can be encoded into monadic effects with dependent types)

>rm isn't safe
It is a program people would like to write

>Just not as horrible as international user wanted to make out to be
No, your solution is just as horrible and isn't scalable at all.
Are you seriously going to do that every time you want to print something?

How do I become a 3 star programmer?

>It doesn't matter what effects IO does, standard Haskell or safe ghc haskell never peeks inside.
What?

>(Which of course can be encoded into monadic effects with dependent types)
And it would be horribly verbose.

>It is a program people would like to write
Well, ideally, simply removing a file would be safe. It's the fault of other programs that it's not. It's kind of a grey area. But this is getting into a whole philosophical discussion of what safety means, when it's really irrelevant to the topic at hand.

You shouldn't need to go beyond 2 stars.
If you're using 3+ stars, you probably need to re-evaluate the design of your program.

What's a 3 star programmer?

>What
It's still pure, whatever effects IO does. Because main is just an IO value.

>and it would be horribly verbose
It would be library code, not on the user end.
Just create a function that takes a non-linear ref computation and possibly returns a linear one if it can guarantee they aren't referenced twice. Otherwise, again you're just embedding it.

It's generally considered a lot nicer to have these things as library features than language ones, especially something like linear types that effects the rest of the type system.

It's about as scalable as the c examples, and it's easy to wrap it into a printf like wrapper if you really want to.

It's how many levels of indirection (pointers) a C programmer uses.

I mean Haskell is still pure.
Main is just an IO computation, to be performed.
Obviously what main does isn't pure, that's the point.

Oh right, that makes sense. I think the most I've used was 2.

>Just create a function that takes a non-linear ref computation and possibly returns a linear one if it can guarantee they aren't referenced twice.
Right, and how do you propose being able to write the code to be checked in such a way that it isn't horribly verbose?

Sounds like you've done something wrong if you end up with a triple pointer.

>and it's easy to wrap it into a printf like wrapper if you really want to
All you've done is create a stupid format pointer implementation. That doesn't counter my argument at all.
>It's about as scalable as the c examples
There is way more variables and extra text involved, duplicated of information and other nonsense.
With C and printf, you can use gettext and your calls just become printf(_("My name is %s.\n"), my_name); and all of the translation is done outside of your program.

How else am I supposed to allocate a 3D array?

>hey user, you know that project due in 6 months that you haven't started yet?
>well the customer wants it in a month now
>here's the 1000 page standard you have to read, drop everything you're doing and have fun

I hate my life

As I said, it's library end. It's not at all trivial if the programs are complicated. You could provide pre-proven, more complicated building blocks.

It's nicer than making it a requirement of the language.
And really, you're just pushing the work off to the compiler writer.

No, that's when you ask for a pay raise and a new title or else you're G O N E.

To the episode list press one more library .imo

All that said, you're still using linear types. What's your point?

I guess you could do single thread IO interleaving, but you can't use ReadKey for that. Does C# have something like PeakKey?

You said linear types
Then you said "I didn't say no dependent types"
If you've got dep. types then you might as well not have linear types built in

Flatten it to 1D.

You're not not using linear types, though.

B-but they are so useful

So what?

Have you changed your mind? Are linear types now only relevant if you've also got dependent types?

Why on earth do you need a 3d array?
Also, as says, 1D is a much better idea.

What? Linear types are relevant anyways, you're just saying that you'd have them as a library feature and not a language feature of a dependently-typed language. I.e. using that language as a logical framework for encoding a language with linear types.

Where are you not using linear types here?

99% of the time, I always end up rewriting my gotos because there's a cleaner way to exit a nested loop structure.

You were saying that you use them for safety, and I said if I wanted safety I'd use dependent types. Linear types by themselves would restrict a bunch of safe but not obviously safe programs.

>All you've done is create a stupid format pointer implementation.
Which is what printf is.

All i'm saying is i don't think iostreams fuck localisation. It's just all about building strings.

Iostreams are still heavyweight, complicated and verbose.

>Linear types by themselves would restrict a bunch of safe but not obviously safe programs.
No more so than using monads instead.

What do monads restrict?

What do linear types restrict?

Using the same value twice

Anyway this discussion has gone on far too long and we're far past what I originally said
Can you please STOP bringing up linear types when I mention monads as a good feature?

All that effectively does is force things to happen in sequence. Which is what monads do.

Yeah I was joking , I'm in a programming class and some guy posted this and said he was the best programmer .

I can't believe these fags are still arguing about this monad thing.

my professor's pet language isn't compiling my stuff properly

We're not arguing about monads, we're arguing about linear fucking types which had nothing fucking to do with what I fucking said
What I fucking said was a ONE OFF FUCKING COMMENT that it would be nice to have a pure lisp with monads (and types, obviously).

This is the THIRD TIME he's felt the need to bring up fucking linear types for no fucking reason

Go on.

>I am angry.
>ANGRY ABOUT LINEAR TYPES

You fucked up

I DEFINITELY should've stopped here
I fucked up again by responding to that stupid faggot

God, I might actually start filtering posts.

filter anything with "python" in it

trust me

Did you fix your boids?

No. My boids are still broken.

put them out of their misery

its alberto barbossa's language you americucks

I don't even know why cause python is not taught at most uni at least not in the regular course

People for some reason decide to learn Python
I have no idea how or why, it's kind of like being chosen by the devil, it just happens

murrican "education" and dpt's "elites", everyone

Beautiful, thanks.

it's quite popular with the data science crowd

for
no
good
reason

I know my Uni had Python for their Intro to Programming course. I had experience and AP credit, so I never learnt it. We used a safer version of C.

here you try it
cs.ecu.edu/karl/cinnameg/8-2/lin/Misc/get.html

i don't know if i'm just going insane. i finally got it compiling things and it gives errors that shouldn't be errors. when i create a type, it says i'm trying to extend a type that already exists but i'm not

cs.ecu.edu/karl/3675/fall16/Assn/Assn4/deriv.cmg

here's the demo file he provided


please just try and let me know if it's just me or if it really is broken. i'm the only one trying to actually install it on my machine, everyone else uses a windows-only virtual machine to connect to a machine that has it installed

Mine was c# but my uni has a partnership with Microsoft so that's is probably why

It's giving me eye cancer, but I can test this binch out for you.

Yeah, that's probably why. Do a lot of your school's grads feed into Microsoft?

Simplicity. Although that is largely going away with Python3 so I have a feeling R is going to take over given its much better suited for the same sorts of tasks.

Not that user, but you're a real human bean.

>lots of libraries for scientific stuff, with great support
>>no good reason

no

good

reason

But R is for statistical analysis only.

They either work for Microsoft or dell but most of them work from less than a year there

The only reason Lisp isn't popular is because people are lazy and dumb

Well, this is definitely not going to work on Winders. I'd need to set up a Linux VM (don't currently have one).

Racket scheme literally has all of the features of Python and the capability for much more. The standard library is bountiful and theres a great C FFI.
People just don't use it because apparently infix notation is too bizzare to handle, or they think it isnt good because KODE WITH KARLY is taught in Python

is karly hot

>Cinnameg is a programming language that allows you to mix declarative (functional and logic) and imperative (including object-oriented) programming seamlessly.

>mix _ and object oriented
>seamless

kodewithklossy.com/

You can do it seamlessly with Swift. You can avoid using objects if you want and can even do functional programming

the answer is yes
i'll be damned

See OCaml. Structural typing can be used to represent OOP-style objects really well in any language with Hindly-Milner types.
Of course, "message passing" is usually a stateful action so that implies lack of functional purity.

I looked her up. She's a fashion model.

>haven't done any programming today
Give me a fizzbuzz or something I can solve before I go to bed.

>OOP style objects

I'm sure you could have a language like Erlang, that's pretty functional as far as each process goes on its own, but the way processes interact, you can have state.

en.wikipedia.org/wiki/Mathematical_object
Pretty much everything is an "object" in some sense or another. Do you prefer to call ints and structs, "datum"?

>ints and structs
>datum
Don't you mean data

modern C++ does a pretty good job of mixing oo/imperative/functional, with less and less template syntax required as time goes on (check out generalized constexpr, constexpr/generic lambdas, variable templates, and the Boost.Hana library, which makes extensive use of those)

Are you seriously now saying that the C term object and the OOP term object are comparable? Or that a simple tuple is now an object?

It honestly doesn't.

At least they didn't call it Entity Oriented Programming.

>C term object
wat

Yes, "object" is also a C term, referring to basically anything that takes up memory
Were you not aware?

I guess I'm filtering the word object now too.

I guess I'm filtering the word filter now

>It honestly doesn't
nice argument. do you actually know what those features are?

Good idea.

I'm saying that you could consider C, or Haskell, or Lisp functions to be manipulating "objects", even if it's not in the sense of OOP objects.
Are you going to go yell at those mathematicians who wrote the wikipedia page?

Its not type safe, though, most of the time gcc can detect errors (but not all the time).

You're right, I should just do it once. it is rare that I need printf style printing and I used to just use some hack to get the desired functionality, rather than spending the time to implement output properly.


I think I might try to implement my own output for C++ and try to optimize it reasonably well, now, and see how much of the computation I can do at compile time. I assume I can get most of it done at compile time with some template trickery, may as well try now.

I'm not familiar with generalised constexpr, I assume it just lets you do more in a constexpr function.

It's wildly different from the OOP sense, because when they say "object" they mean object in the "thing" sense.
So imagine someone invented a technical term, "Thing", and developed "Thing Oriented Programming", and then someone said "XYZ language must be TOP! It involves things, even if they aren't the Things from TOP"

Is it bad if I have a nested loop that's 4 levels deep?
I ended up using i, j, k, and l for iterator variables.

Everybody needs to shut the fuck up.

It's probably time to split your functionality into different procedures.
Filtered.

Cinnameg guy, if you're still here, I'm still working on it. VM is installing Lubuntu as we speak.

Exactly.
Things in C are called objects but I never meant to claim that C is OOP

>i and l
Don't do this. Yeah yeah on a proper font blah blah. There's no advantage to it so just don't.

>the fucking state of swift's documentation

what, should I use m instead?

how many of these goddamn bootcamps are there
does the world need so many emitters of mediocre javascript

thanks for the attempt

there's a whole alphabet of letters out there, just waiting to be found

We're just on the cusp of a second tech bubble burst.
99% of new startups make no profit and are only being held together on shit JS backend code and venture capital funding with no plans to ever become profitable.

See: I'm still working on it, lad.

error: stray ‘\343’ in program
unsigned i, j, k, あ;
^

>I think I might try to implement my own output for C++ and try to optimize it reasonably well, now, and see how much of the computation I can do at compile time.
I'm interested in seeing the results.

Lately i've been feeling i should learn how to do efficient string handling and parsing, rather than the naive solutions you get from all the basic textbooks.

Anyone have any good reading resources on that matter?

you could use that character in swift (^:

oh i see. thank you very much. if you try to install it while in /usr and run into problems, you may try to create a directory in home for it, and then untar it and run the commands there. if it says something about yacc t_parser.c you have to go into src and parsers i believe, and then touch t_parser.c to update the modified date to right now. that's my wisdom imparted to you. i'm going try to see the professor at his office hours this morning to ask him for tech help regardless

ah, that's a problem

Shit-ter language

$ ghci
λ: let あ = 2
λ: あ
2

use clang

>can't do this on windows
>can't run ghci on bash on ubuntu on windows because no timer_create
life is suffering

me@me:~$ ghci
GHCi, version 7.6.3: haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> let あ = 2
Prelude> あ
2
Prelude>


neat

it lets you do anything in a constexpr function as long it's actually a constant expression, including branching/switching/loops. so, assuming you're writing/using code that is properly constexpr-qualified, you can do anything except what can't be constexpr by nature (disk IO, keyboard/mouse input, etc). combine that with template variables/functions and constexpr/generic lambdas and you can have higher-order functions and such, all still constexpr. i really recommend checking out Boost.Hana if you haven't

I have post traumatic stress from that one thing i did in swift. Now everytime someone mentions swift i get the overwhelming urge to declare that swift is a troll language.
Seriously, coding in swift and that apple ide i don't remember the name of felt like i was using Cred Forums as my ide and compiler.

youtube.com/watch?v=zBkNBP00wJE

it'll be good once they purge the last vestiges of obj*ct*v*-c 2bh

Interestingly, I was just about to post that.

oh and i forgot to mention generalized return type deduction and decltype/declval. those obviously play a big part too

Just started learning the game maker language, literally have no idea why this character isnt moving left when i press the designated key...
any help please?
Heres the code.
Character also wont jump, but moves to the right when i press the designated key

///Get the player's input
key_right = keyboard_check(ord("D"));
key_left = keyboard_check(ord("A"));
key_jump = keyboard_check_pressed(vk_space);
//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;

if (place_meeting(x,y+1,obj_wall))
{
vsp = key_jump * -jumpspeed
}
//Horizontal Collision
if (place_meeting(x+hsp,y,obj_wall))
{
while(!place_meeting(x+sign(hsp),y,obj_wall))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
//Verticle Collision
{
if (place_meeting(x,y+vsp,obj_wall))
while(!place_meeting(x,y+sign(vsp),obj_wall))
{
y += sign(vsp);
}
vsp = 0;
}

y += vsp;

He said alphabet. あ is part of a syllabary, not an alphabet. Besides non-shit languages would let you use that as a name.

What happened?

Anyways, I've been trying to solve cryptopals with it, but I'm trying to also make my code portable with Ubuntu and OSX, so I'm not using and IDE.

you, me, and the professor himself may genuinely be the only 3 people in the world to do this.

i'm rather tech illiterate so i tend to blindly copy and paste things but i looked at this command
./configure --prefix=/usr/local/lib/Cinnameg/8-2-1 --exec-prefix=/usr/local
and im wondering if maybe changing the prefix to something in home will fix the problems i'm having. you can try it out for yourself as well if your normal install doesn't work. i don't know why that'd make it work i just know that putting the files in home worked for something previously

Unicode should not be part of source code.

This is how you end up with shit code like pic related.

...

No, the problem there is that emojis fucking exist and are in that character set

How/Can I use std cin to nothing?

Why is this so jarring?
I know they're being used as letters, but I can't make myself see stupid pictures as forming words.

> -> Void
for what purpose?

To prove that it can't be run, probably.

I was about to defend it, but then I remembered that it's unnecessary.

trying to get syntax highlighting to work in Padre with Perl 6.

anyone had any experience with this?

>Hardmode: its a work computer so I have to use Windows 10, and not something Unix based like a sane person

No matter what I do, the make gives me an error at line 89

target '/usr/local/lib/Cinnameg/8-2-1/lib/native' is not a directory

I don't think the problem would be alleviated if you had Chinese characters or Cryllic letters instead.

Because emojis are supposed to be images, not writing glyphs.

It means the function doesn't return anything in Swift. It's not super bad, but I rather the C version of annotating what the function will return.

>Functions are not required to define a return type. Here’s a version of the greet(person:) function, which prints its own String value rather than returning it:
func greet(person: String) {
print("Hello, \(person)!")
}
greet(person: "Dave")
// Prints "Hello, Dave!"

>Because it does not need to return a value, the function’s definition does not include the return arrow (->) or a return type.

I know what it means m8 I'm just saying it's a waste of time

>it does not need to return a value
not
a
function

It just seemed incredibly inconsistent. I never really got a grip on the design logic. It was like the ide was actively listening in me and my pair programming partner trying to understand the language, and kept changing the rules just to troll us.

*tips*

wat?

What?

I didn't know it was optional but that's almost as bad as C++ defining these two functions to mean the same thing and C mistakenly having the same semantics as well.

int main()
int main(void)

yep it gave me that when i tried to put it in usr. try making a directory in home called cinnameg with a subdirectory 8-2-1, and put everything in there. and change this command
./configure --prefix=/usr/local/lib/Cinnameg/8-2-1 --exec-prefix=/usr/local
to suit that. i'd change exec-prefix to home too and got it semi working. now all im doing is waiting to see if this works

Because you're brain is unable to attach syllables to the symbols, making it incredibly hard to pars.

*mistakenly assumed to have the same semantics as well

I should sleep soon

>excuse me, but I think you'll find that TECHNICALLY a function is not a function if it does not return a value. contrary to popular belief, this is in fact known as a "procedure". please avoid making this mistake in future, you uneducated plebeian

If you run the config script with $PWD, it's built in the local folder, and then you can cd to bin and run the interpreter

I didn't mean to trigger you

>using trigger unironically
>>>tumblr

>using trigger ironically

so you mean to untar it, and then instead of
./configure --prefix=/usr/local/lib/Cinnameg/8-2-1 --exec-prefix=/usr/local
do ./configure $PWD ? like i said i normally just copy and paste things. by interpreter, do you mean i can compile and run files or something different?

...

more like >>>/(You)s/ lmao sucker

>I don't think the problem would be alleviated if you had Chinese characters or Cryllic letters instead.
Chinese characters are actually comfy as fuck for variable names. You get basically 1/2-letter long names that hold as much meaning as words.

string 名 = "John Wang";
string 国籍 = "American";
int 歳 = 30;
string 出身 = "China";

Sadly the whole world doesn't speak Chinese (or Japanese in the case of my examples), otherwise they would be superior to english words as far as variable names go.

You set prefix to $PWD and exec-prefix to $PWD. That said, it seems to shit itself on that "demo" file you gave me.

>making all your variable names indistinguishable from each other
>a good idea

not if you can read it dickhead
those all look totally different to me

>I don't understand it therefore its universallt incomprehensible
>>>/retardation/

>>making all your variable names indistinguishable from each other
Yeah indistinguishable... in the same way that when a chinese person reads the newspaper all he sees is "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" right? Because the characters arr rook same?

spotted the weebs

i did
./configure --prefix=$PWD --exec-prefix=$PWD
and now tried
justin@debian:~/Documents/academic/3675/assn4$ cmgc deriv
Wrote listing to file deriv.lst
justin@debian:~/Documents/academic/3675/assn4$ cmgc testderiv
Wrote listing to file testderiv.lst
justin@debian:~/Documents/academic/3675/assn4$ cmgr testderiv
Cannot find compiler /usr/local/lib/Cinnameg/8-2-1/bin/cmgc
Cannot open file /usr/local/lib/Cinnameg/8-2-1/lib/standard.cmo
justin@debian:~/Documents/academic/3675/assn4$


previously today, i got bogus errors trying to cmgc deriv. now i don't, but i get this error. it looks like a more sane error. got any ideas on what i should do different?

>chinese
>weeb
you got me though, good troll

...

You know what's weird? I run the include test suite and it all seems to work, but I can't even get my own hello world to compile.

>Perl 6
I don't think anybody has experience with Perl 6

i'm going to have to see him tomorrow morning. thanks for the help. nite nite

WE HAVE LIFTOFF. I REPEAT, WE HAVE LIFTOFF!

did you do anything special?

Just found a file that actually worked. The very first sample program on his page.

I am probably the first person outside of your university to ever successfully compile a Cinnameg program.

I'm going to put this shit on my resume.

Tbh, this language is not that bad. I mean, I don't like some of the design choices, but it seems to have every feature under the sun, including Monads™

I looked at the demo code and it reminded me of Haskell

>No linear types

there's no doubt you are. grats i guess i'm still trying to figure it out myself

oh wtf i copy and pasted the cmgr file into the file and now it works

this is the most ghetto rig i've ever used but it may be what i use all semester

More accurately, it's a clusterfuck of everything. One of the testfiles even includes the canonical Haslel """"quicksort"""".

*i meant i copy and pasted the cmgr file into the directory with my test code, and then did ./cmgr test
sleepy time here i go

I don't know if it's lazy, but if it isn't then that's a really inefficient quicksort

$ gore
gore version 0.2.6 :help for help
gore> あ := 2
2
gore> あ
2
gore>

had no idea Go supports unicode in the source code

>this is the most ghetto rig i've ever used but it may be what i use all semester

Tell your prof I helped so I can get some extra credit.

When he adds me to the class roll, I want to be "Spede Pasanen"

Yes, it is. Cinnameg is the future, everybody.

i got overly excited. hello world works but it still doesn't work for the deriv and testderiv files. i'm still going to have to wake up early and see him. i'll tell him you say hi though

ADTs and case expressions is nice though

Do you guys still play video games if you have a full time job?

only if you have literally zero life to speak of

Are you sure the test file isn't written in Cinnameg 9.0? This is 8.2 we're using here.

It needs more memes, though. Where's muh HKTs?

I did when I first got out of school and was working while living at home with the parents and super bored all the time but I eventually moved out and got hobbies.

you have to do things to be interesting to make conversation to meet women.

Video games are ""fun""

Does it even have arrow kinds?
Are there type constructors?

Does it have polymorphic recursion?
Then he could've used a generalised catamorphism for his deriv:
deriv = cata deriv'

deriv' constant(?) = 0
deriv' xx = 1
deriv' (a + b) = a + b

NO! CINNAMEG A SHIT! REEEEEE

data Expr r = XX | Constant Double | r + r

Then you use the type-level fixpoint operator
data Fix f = Fix (f (Fix f))
So
Fix Expr
becomes
Expr (Fix Expr)
Expr (Expr (Fix Expr))
Expr (Expr (...))

This is as an alternative to

data Expr = XX | Constant Double | Expr + Expr

The benefit you get is generalised catamorphisms

unfix (Fix f) = f
cata f = f . fmap (cata f) . unfix

To be honest, chief, you lost me a while ago. All I know is that Cinnameg does not have these super fancy type theory sounding things.

osgtp im on my phone in bed but can you do something for me and check to see how involved that online interpreter is? i remember seeing one. i just realized i may be wasting my time trying to get it running on my own computer. does it allow uploading .cmg files and stuff?

His online interpreter is shit and has a million restrictions.

ok. in going to sleep now. dont let me wake up

>getting a trip to do your homework for you from your bed
>those digits

I didn't do his HW, though, I just helped him figure out how to get this shitheap of a compiler to successfully compile.

cata f
Imagine f is an "eval" function for an expression, but unlike a regular eval function, it assumes sub-expressions are already evaluated.

I.e. for a binary tree
data Tree = Leaf Int | Split Tree Tree
this "weird" eval function acts like it's actually defined as
data Tree = Leaf Int | Split Result Result
(where Result is the type that eval would give back)

The cata bit transforms f so that it evaluates all the nested expressions first (using f)

So for instance

count' (Leaf _) = 1
count' (Split a b) = a + b
count = cata count'

vs

count (Leaf _) = 1
count (Split a b) = count a + count b

Notice how in the second, the recursion is explicit, but in the first, it was like the input (Split a b) already contained the count of the subtrees

How am I supposed to make sure that a DirectX application will run on every machine? By every I mean that at least on Win 7-8-10?

Right now I'm testing it on another machine, and I get missing DLL errors. When I read about those, the official MS site tells me that I need to install the SDK to solve the issue (that's why I didn't get the error on the dev machine). I could pack those with the executable, of course, but isn't the whole point of DX that it should find everything already on the machine? Or am I following an outdated tutorial? rastertek.com/tutdx11.html

You bundle the DLLS. You don't need the whole SDK, just the runtime.

Why can't I use a negative number as an array index?

Have you noticed that pretty much every game also installs a Visual C++ Redistributable when installing the game?

Because you're not using Python anymore, Toto.

Ah, so there's no escape then.

>every game also installs a Visual C++ Redistributable when installing the game
Now it makes sense.

I'd like to peek at the char at the address right before s, but I don't know how to do that without explicitly writing it like this.

while (*(s - 1) == '\n') s--;

c
#include

void
rput (void)
{
char c = getchar();
if (c != '\n') {
rput();
putchar(c);
}
}

int
main ()
{
printf("string?: ");
rput();
putchar('\n');
}


haskell
rput = do
c > putChar c
else return ()

main = do
putStr "string: "
rput
putChar '\n'

It's also possible to compile your program using static linking, obviating the need for dll's. That may or may not bloat your executable, depending on the size and structure of your code base.

I'm following mysqltutorial.org/mysql-subquery/
And I'm confused on correlated subqueries
SELECT
productname,
buyprice
FROM
products AS p1
WHERE
buyprice > (
SELECT
AVG(buyprice)
FROM
products
WHERE
productline = p1.productline
)
So in the subquery it's getting the average for each product line? How is the outer query knowing which productline to compare to though

prev = s[0];
for (i= 1; i< s.length; i++) {
curr = s[i];

// do whatever you want with current and previous value here

prev = curr;
}

instead of
s[-i]

do
*(s-i)

What's wrong with s[-1]?

>K&R Section 5.3: If one is sure that the elements exist, it is also possible to index backwards in an array; p[-1], p[-2], and so on are syntactically legal, and refer to the elements that immediately precede p[0]. Of course, it is illegal to refer to objects that are not within the array bounds.

>non-tail recursive function with indefinite input length
You're asking for a stack overflow, user.

>haskek
>terse
camelCase
>readability of perl scripts

>c
>beautiful
>self commenting code

Nothing. My brain is just mush and needs sleep.

non-tail?

i think the self commenting of c code just comes down to familiarity,

Can a function be TCO if the input is indefinite?

You have actions after the recursive call. So what you're doing is basically building the string on the call stack and then printing it in reverse order. If you're going to be building a stack to reverse print an input, you should use the heap with malloc and realloc. I could write up a proper example of doing this if you give me a couple of minutes.

good job

where you learning from

>Alright, your new title is senior codemonkey and you get one extra banana per day. Now get back to work, faggot.

>Ye.. Yes sir...

do it

Yes. You can write a simple infinite loop using recursion, and an optimizing compiler can usually turn it into a normal infinite loop. TCO doesn't occur when you have actions that occur after the recursive call. Although some simple actions like multiplication and addition can be optimized anyways. The classic recursive factorial function (n * fact(n - 1)) isn't tail recursive, but can nonetheless be optimized to one.

>if cond then act else return ()
use when from Control.Monad

rput = do
c

It would take me 3 months, at least, just to read 1000 pages.

when (c /= '\n') (rput >> putChar c)
?

I wouldn't put it all on one line

so, is void a hack that was thrown in in c just so that one can work on a general type of containers?

void as a generic pointer type is definitely an ill-conceived hack
it wasn't even part of the language until C89.

Rob Pike is a nice and funny man but I won't deny he looks like an elf in his older age. Maybe it's a good thing.

No wonder he hates C++
Elves hate gnomes

Friendly reminder to const qualify your data where appropriate.
Contrary to popular belief, const DOES help the compiler to optimize.

#include
#include

void rput(void)
{
size_t cap = 1024;
size_t len = 0;

char c;
char *tmp;
char *buf = malloc(cap);

if (!buf) goto OutOfMemory;

/* Read string into heap allocated buffer, resizing as necessary */
do {
c = getchar();
if (len == cap) {
cap *= 2;
tmp = realloc(buf, cap);
if (tmp) { buf = tmp; }
else { goto OutOfMemory; }
}
buf[len++] = c;
} while (c != '\n');

/* Print characters in reverse order */
len--;
while (len) putchar(buf[--len]);

goto Cleanup;

OutOfMemory:
fprintf(stderr, "error: insufficient heap memory\n");
Cleanup:
free(buf);
}

int main(void)
{
printf("string?: ");
rput();
putchar('\n');
}

If I have a const array of strings, do I have to const the string pointers themselves with
static const char *const arr[] = { ...

I'm not sure, you'd have to ask someone who is familiar with const pointers.

My guess is that yes you probably do.

Is that even C++ standard conformant? I am guessing since there is no restrict in C++ and the semantics for const is slightly different than C, it is legal for this to happen.

how to get assembler output from gcc???

very stupid frogposter

gcc -S

How about you stop posting frogs and learn to google you underage fucking faggot.

I think reading the man page might be a faster option.

It's even simpler to do this program in C++

#include
#include

void rput()
{
std::string str; // std::string is an auto-resizing container
std::cin >> str; // iostreams handle this seamlessly behind the scenes

// Reverse iterators take care of needing to keep track of indices
for (auto rit = str.rbegin(); rit != str.rend(); ++rit) {
std::cout

ill google my micropenis into your mum's dungeon fagets

A frogposter can never become a man

Take that, iostream haters.

main = interact reverse
rate my haskell code

It's shit.

illegible/10

>it's destructor is called
>it's

way too hard to read

*it's destructor its called

your and idiot

impractical/10

0/10

It has its advantages and its disadvantages.

gets.reverse.display

Yeah, I derped.

interact is a really nice function for this sort of thing

takes a string->string function, applies it to stdin, then returns that as stdout

C++ is so strange and arcane it may as well be it's own programming paradigm.

Non-blocking console io is probably the best your gonna get.
I'll post code when I'm done being a (((mobile poster)))

C++ is proof that 1000 typewriters sitting on a committee CANNOT reproduce shakespeare

haskell/10

At least you'd think their committee is made of typewriters, given how many books they write that exist solely to explain the stupid decisions they've made

Clang or GCC?

Depends, are you an S or an M?

Sounds pretty useful if you're doing a lot of shit with stdin.

def interact
puts yield gets
end
interact &:reverse

Can you improve on this code?
try {

} catch (彼女) {
throw new 彼女(KanojoAttribute.性病);
}

//done

"useful" is how i'd describe most of the functions in Haskell's standard library

higher order functions are one of many reasons why FP is goat

пoпpoбyй {

} cлoви (彼女) {
кинь нoвый 彼女(KanojoAttribute.性病);
}
*
"GRUNNUR"
;

I want to write a bunch of functions to help me prepare WebGL attributes and buffers, but I don't have any good and brief documentation on the pipeline.

I approve of this, but I heard goto is harmful.

It gives you brain cancer

Avoid at all costs. I heard that if Goto bites you, you also become a Goto.

why?
it's really useful, allows you to jump to wherever you want

What do people who get a degree in cs do other than be code monkeys?

>don't get degree in cs
>realise you are shit
>>heh stupid csfags

It's pretty good, you don't even need functions so performance is maximum!

so gotos are functions?

he's in his own little world where function means C compliant function call

NEW THREAD
NEW THREAD
NEW THREAD
NEW THREAD
boards.Cred Forums.org/g/thread/56819162NEW THREAD

QA monkey

Research.

that's huehue not tacospeak, daily reminder that the u.s. stereotype is being ignorant and elitist

anyone here do any programming on their android device? I am constantly commuting and wonder if I can code on the go

Do you work for a company? If so, the management is shit. Just say you're going to try your best but you're going to fail, then fail, while collecting your biweeklies.

Don't ever try to make ends meet with unrealistic deadlines. Work at your own pace, write quality code, and fuck every1 else. If they keep on doing it just go find another job and let them use a pajeet programmer