/dpt/ - Daily Programming Thread

Old thread: What are you working on Cred Forums?

Other urls found in this thread:

en.wikipedia.org/wiki/ANSI_escape_code
gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html
hackage.haskell.org/package/base-4.9.0.0/docs/Data-Monoid.html
ghostbin.com/paste/5ktg7
degoes.net/articles/modern-fp-part-2
twitter.com/SFWRedditImages

Rewriting the linux kernel in Scratch

>arbitrarily defining what "inverting a binary tree" means all by yourself
>even if it's the intuitive definition
I have problems with this

the least kawaii trap op image

please use himegota next time

I'm not divulging the company name here.
Yes. Their email to me started with how impressed they were with my handling of the company bots on codefights.

Hope that helps. I am off to bed.

>I'm not divulging the company name here.
Why not? If it's big name there's no risk.

He's probably one in like, two or three people that got scouted via that website.
It's pretty obvious.

Still working on my metronome.

I have problem where i sometimes want to start playing a sample again before it has ended playing, but it wont let me.

So now i probably have to make an ugly solution where i have the same sample in several audio objects and fire them off sequentially. Maybe that'll work.

This is what you get for listening to Cred Forums and using a high level API.

A big name company is going to be scouting more people than that m8.

The dictionary definition of invert is to "put upside down or in the opposite position, order, or arrangement."

It's not an arbitrary definition if it works with the dictionary definition.

I just thought of something -- since Image/Bitmap just wrap GDI+, you could also skirt the whole 65kx65k res limit from GDI if you wrote your own parser and used a simple FastImage class. That'd give you a lot more latitude in working on huge files (scanned maps, etc).

But what does it mean to put a graph upside down?

enum format_tag {
CODE_L, CODE_R,
SPOILER_L, SPOILER_R,
/* ~~ */
SUPPORTED_TAGS /* total enum count (should be 4) */
};

Is this undefined behavior?

But what if they want the tree to be upside down?

Observe!

Nope. That should map to zero through four.

That's the same graph, it's not changed.

SURPRISE

My random image generator program works with big ol images. I'm going to cum on the fucking floor if I don't figure out why it can't produce anything smaller than 210x210 without segfaulting

Post yer source fag

I'm on mobile and my wifi adapter isn't working :^(

I'm going to rewrite the broken stuff tomorrow morning

Likely story. We won't bully unless it's really bad.

Tether your phone to your computer over usb and use your phone's wifi user-senpai.

Flipping left and right is also the same graph.

Not at all.
It's completely well-defined, and I've even seen several libraries do that.

Accshually, formally you havent put the graph upside down; just the embedding of the graph. So *nyeh*

it's too late I've already broken out gdb and I'm gonna get to the bottom of this

why does she have one of those turkish hats

Computer Science was invented in Ottoman Empire.

One of the authors of SICP, Hal Abelson shows up in the SICP video lectures wearing that hat.

nice try lol

WE

Trying desperately to drown my emotions in alcohol.
I don't want to go back to work and keep having to write powershell scripts.
I really, really don't want to.
They're so obtuse.

polish up that resume this weekend user

That's what I've been working on. Going to go to some of the career fairs this year and see what's out there.

I once had to rotate a binary tree 360 degrees

Incredible.

I couldn't do it so I turned 2pi radians and walked away

So this needs an adjacency list of includes right?

main.cpp -> Class1.hpp, Class2.hpp
Class2.hpp -> Class1.hpp, Class2.cpp
Class1.hpp -> Class1.cpp

I currently implement it like that but my algorithm to detect it only detects -PAIRS- of redundancy and not more than two. It just compares the includes of one file against that includes' includes.

Another Idea I thought about involves having the adjacency list being a list of the includes and its "includers":


Class1.hpp -> Class1.cpp, main.cpp, Class2.hpp
Class2.hpp -> main.cpp, Class2.cpp

but i dont know the algorithm to detect a redundancy that doesn't involve some crazy as hell recursion that could potentially cycle into infinity.

And then you learn about include guards, and header file pollution is no longer.

pragma once

#

P
NOT
R
T
A
B
L
E

You're doing it wrong


P
N O T
R
T
A
B
L
E

The power of C compels you!

POT NORTABLE!

P
O
R
N O T
A
B
L
E

That's not a proper cross

pls help

C
R
N O T
S
S
[/core]

>tfw building a web frontend for your project

I am either going to kill the creator of CSS or myself

>frogposter
>webdev
It all makes sense now

would an adjacency matrix make this easier i forget

not a webdev this is just for fun :^)

hey /dpt/ rate my 1337 hacker code
#include
#include
main()
{
printf("Hack world y or n?\n");
hackEngage.Start();
)

I think I just went retarded with my pointers, I just don't get why it works most of the time

i love my waifus so much...

webdevs are the only solo devs that can make money

Tips for learning pointers in C? I'm reading the holy book right now but it just isn't clicking 100% for some reason, what else should I look at.

Doesn't compile

git gud it's easy you fucking scrup

How do I become a 4 star programmer, Cred Forums?

You must vibrate higher and transcend this dimension

pls help

...

#define ptr(a) a*
Now you're a one star programmer

A pointer is just a variable that holds a memory address.
Dereference it with * or [] to see the data that address points to.

You can go pretty deep with pointers, especially when working with structs made of multi-dimensional pointers.

I saw death grips live they were cool

I guess I'm just not grasping when to use them

You can pass pointers into a function instead of just a value

In C, is there any library or function that lets me change the color of characters onscreen? I don't want to do this with syscalls because it would be really long and add a ton of lines to the code.

What I'm trying to do is:
- make a simple system that shows four rows of seats
- seats that are taken are shown in yellow
- seats that are free are shown in green

see

Why not syscalls?

Why not make your adjacency list contain only a files includers? Then each file that has an adjacency list larger than 1 is a problem file.

there is probably some library that will try to do the right thing depending on the system

I'll give an example.
char *str = (char *) malloc(sizeof(char) * 6);
memcpy(str, "hello", 6);
str[5] = '\0'; /* null terminate */
/* or */
*(str + 5) = '\0'
/* or */
char *p = &str[5];
*p = '\0';
All of the above do the same thing.
Literally everything and everything in C is an abstraction built around pointers and pointer arithmetic.

system ("color 0A")
Now everything is green. I only want to make certain characters a certain color, like the extended ls does in linux.

Btw, I'm using windows.

When you need to use them, you'll know it.

windows.h

en.wikipedia.org/wiki/ANSI_escape_code
#include

#define YELLOW "\033[33m"
#define RESET "\033[0m"

int main()
{
printf(YELLOW"test\n"RESET);
}

Thank you so much for the example, that actually helps a lot.

windows.h

SetConsoleTextAttribute()

Wow, how does this work on black and white only monitors?

Use ncurses. Yes it works on Windows. No, you shouldn't use the system() function at all.

is this really it?

Wouldn't you need to resolve/trace some directional stuff to detect upwards?

else it would be "Class1.cpp, main.cpp, Class2.hpp"
when it should just be "main.cpp, Class2.hpp"

Thanks for the answers.

It would presumably do nothing.

This is actually an interesting problem, now that I think about it.
Turn a binary tree "upside down", by making link lists for each of its leafs that lead to the root.
e.g.
; binary tree:
4
/ \
2 5
/ \ \
1 3 6
; represented by:
(tree (tree (leaf 1)
2
(leaf 3))
4
(tree #f
5
(leaf 6)))
; upside-down:
((1 2 4) (3 2 4) (6 5 4))

It depends on the behaviour of your terminal.

That's one of the solutions that people have come up with for what it means to "invert" the tree. That is, each leaf becomes a parent and leads down to the original root.

ANSI escape codes actually don't work on Windows, IIRC. You basically have to use the windows.h stuff. Libraries like ncurses abstract all of this behind portable function calls. On Windows, it might use the Win32 API to handle console manipulation, while on Unix-like systems, ANSI escape codes might be used.

According to the Wikipedia article, BotnetOS 10 supports ANSI escape codes.

How would you go about simulating a NFA in C? I'm using linked lists to represent sets but it feels like I'm being very inefficient

A masochist I see.

btw here is a solution
(struct tree (left val right))
(struct leaf (val))

(define (upside-down t)
(cond
[(false? t) '()]
[(tree? t)
(map (lambda (x) (cons (tree-val t) x))
(append (upside-down (tree-left t))
(upside-down (tree-right t))))]
[(leaf? t) (list (leaf-val t))]))

goodnight

I tested this on Windows 7, and it doesn't work on Command Prompt. I was curious because I remember my teacher from 7 years ago teaching this, but I believe he said it was based on the terminal emulator implementation. I remember he showed it to us using a really old hardware text terminal.

Generating is not the problem. Its detecting the redundancies.

for each file f in files:
for each include i in f:
adjacency[i].add(f);

Fixed a typo. Now i don't see a problem.

Efficient simulation of nondeterminism -> P=NP.

As i said: each file that is included more than once will have an adjacency list larger than 1. I still don't see the problem.

im starting a c# book, so I downloaded project rider from jetbrains, would anyone tell me if im beter off using mono or net core? im on debian

>else it would be "Class1.cpp, main.cpp, Class2.hpp"
>when it should just be "main.cpp, Class2.hpp"

given the adjacency list:

Class1.hpp -> Class1.cpp, main.cpp, Class2.hpp
Class2.hpp -> main.cpp, Class2.cpp

just going by "more than one" wouldn't really be accurate would it?

how about if it's an odd amount.

or something-something detecting if its directional vs undirectional

/*Calculate the hypotenuse of a right triangle given a and b using the Pythagorean theorem a^2 + b^2 =c^2*/

#include
#include


int main()
{
float a;
float b;
float c;

printf("Please enter the first side of your triangle: ");
scanf("%f", &a);

pow(a, 2);

printf("Please enter the second side of your traingle: ");
scanf("%f", &b);

pow(b, 2);


c = (a * b);


printf("The hypoteneuse of your triangle is %f ", c);

}

Can someone show me how to fix this in C? I have to use the pow and sqrrt function. I would sqrt the c and the left side to simplify, but not sure how to go about it.

Congratulations. Babbys second program.

c = sqrt( pow(a,2) + pow(b,2) );

Just like math.

>c = (a * b);
what are you doing m8

Peterr?!?

Lets ignore reality for a bit and just consider the problem of a file being included by multiple include files. Then my solution would work, right?

What would happen if you did that and then consider yeah compilation unit (.cpp file) as a separate project?

>c = (a * b)
Please tell me where are you going with this.

>and then consider yeah compilation unit (.cpp file) as a separate project?
boy wat
just ignore cpp files?

wouldnt that not let main.cpp detect its redundancy then? This is for an assignment yoy

The system function is not a syscall.

Whats a better "First' language Java or C#? How hard is it to learn syntax/basics of making shit and how long does it take you guys to transition over to a new language? I jsut want to make neat, shitty little programs and feel like I'm doing something with my life.

>yeah compilation
wtf, how did i typo 'each' this badly?

I mean dividing the the problem into several independent sub problems. Ignore cpp files for one sub and only consider one cpp file at a time for the other sub.

C#

>I jsut want to make neat, shitty little programs
Haskell

So will you guys help me understand something, or do I need to go to /sqt/ for that?

If it's programming related, then probably

mono or net core!?!?!?

I dare not answer this question, for fear of having to eat my words.

Common Lisp or Racket.

pls

I don't know, but i think C# is a better investment of time.

It is. I'm having a hard time grasping classes and how to set one up.

I'm not trying to make anyone eat their words here.

...

>le
>m8
Fuck off

/dpt/ is not averse to helping noobs, but sometimes the questions are just too stupid

What have you seen before that qualifies as such?
>inb4 mine

Trying to make a homebrew Hebrew gematria calculator. There are several on the web but I wanted to test myself after a month of learning C++. What can I improve? Most importantly, how do I finish it?

>compile java project
>can't find class files for library
>fiddle with class path and crap for hours
>still doesn't work

why wouldn't you use a language that favors parentheses in this case

Oh, there was this one earlier today that couldn't make herself understood because she didn't understand the difference between a class and an object, and refused to read a book.

Actually, come to think, that might have been you. Was that you?

tfw no programming anime gf

...

I just pucked up c and wew memory apis make me so very not happy.

I'm two semesters into my Comp Sci Major (first semester this past winter fml) and all I know how to work with is a little JavaScript, C++, and HTML.

those are illegal variable names in c++

Shiet

Does C preprocessor abuse count as metaprogramming?

Do it in Python for unicode support and easy peasy text handling.

I'm not a grill.

Odd coincidence though.

How many threads behind? Kind of want to see it.

Also, lines 16 and 17 are fucked.

I believe Python is next semester. I'll put this project on the back burner for now then. Thx anyway!

If you have the time it's no harm learning it now and doing the project.
It should be really easy to learn enough Python to at least get started and it will give you a headstart on your classes next semester.

...

kek
I like to think I'm a bit more competent than that at least.

...

Here's what I got so far using the adjacency list of includes.

It only does pairs for w/e reason

C in 2016 LUL

...

what do you use then?

drumpf or killary

not him but I use HTML

i use css
lets make videogamez

Johnson. Or Stein. Either is a better choice, to be honest.

Why not?

johnson is retarded
>what is a leppo
and stein is a commie

I would rather someone who knows literally nothing about foreign policy than either Hillary or Trump. We need someone to restore all of the civil liberties the past several presidents ripped away from us anyways.

trump: make america great again
hillary: 30 years of change
johnson: what is a leppo
stein: the foxes are guarding the chicken coop

hes not retarded, he's just high

I want to start learning about drivers. Specifically, webcam drivers. I'm going to man up and actually do that shit.
Where do I start? I know a bit of C++ but,

Today I actually googled "how to write a write driver in python"! Please kill me.

Any links/books would be appreciated.

can somebody tell me what's going wrong?

>how to write driver in python
You can't. There's no Python interpreter in the kernel of any major OS.

Could you write python driver?

>implying anyone on Cred Forums has ever interfaced with hardware directly

You can write a C module for python that is a driver.
:^)

For a record you want

Date { day = ..., month = ..., year = ... }
or

Date x y z

>std::string is now considered "raw"
The fuck? what's the "modern" string type in C++ now?

can you remind me how to reverse pattern match?

like
Just n = lookup something list
is that the sytax?

That works

Just think of a pattern as like an identifier.
In any situation where you could be using an identifier / a variable name, you could also be using a pattern

>using the smiley with a carat nose

I see, then, how come, my shit doesn't work?

Java is obviously better but I wouldn't take it as a first language. Do c or something

You literally want

Date { day = read (take 2 d')
, ...

or
You don't actually "reverse pattern match" anywhere

by or I was about to say

Date
read (take 2 d')
..
..

no sorry, I mean that when I do
Just n = lookup x xs

You can only define top level bindings that way

Do you mean to do a let binding, a where binding, a lambda abstraction, etc?

im doing in in a let
I would show code, but I'm super embarrased
it looke like very pajeet

Post the code pajeet

>install GSL
>everything is in order
>call gsl_sf_hypergeo.h in code
>get "undefined reference to gsl_sf_hypergeoU" error in compiler
>literally have no idea how to link library to code
>the manual is absolutely useless
>mfw

What's a good C exercises book

I know all the syntaxes but they are useless if I can't apply them

be mercy

What's the error you're getting?

hold on
im still fixing i

You might be able to write a driver that is a python interpreter and runs python code in the kernel, but that would be beyond retarded.

Err... no. C modules are just dynamically loaded libraries. The Python application is still just a user process. There is no way to elevate a user process to run as a kernel module in pretty much any major OS.

What's wrong with CSS?

help!

>but that would be beyond retarded.
n-no it not

>what i said is not retarded
>frogpost

You couldn't make it up

Just imagine a type error taking the entire operating system down with it.

Are you telling me you've never needed to use
for (...)
elif (...)
when writing an OS?

Every language can have errors.

i am an idiot and have this "undefined reference class::member" problem using gcc/make. i know it's a linker issue. i'm in the middle of this huge multi-tiered make project and i'm trying to use some of the classes. i am using code::blocks.

i have a dozen or so #include lines and code::blocks can easily find the function declarations in the .h files and lets me do autocomplete stuff just fine. i know i am missing something stupid and simple, but what? the .h files and the .cc files are in different dirs, but the project compiles fine with ./configure; make; make install.

this project is so complex. they overloaded bool and cout and implemented their own streams for file handling so i can't just fopen() if i want to use their parsing member functions. this is the exact kind of stuff that made me hate c++.

Some more than others

no /wdg/ so i'll ask here

whats the difference between a controller and model? why is it if i'm routing a request from a post method i should ssend it to a controller as opposed to a model?

OOP is bad

Controllaz are just request handlers.
Models mirror what is kept in yo data base

I'm a dev, but I have to interview a PM joining our team, what questions should I even ask..?

>Controllaz are just request handlers.

ah so thats why it handles the post request? i still don't really understand what models do though. i imagine if you have a lot of processing which needs to be done on the data in your DB you'd do that in the model?

What's a PM?

A modified trolley problem to make it sound relevant to pm's job.

why is a dev interviewing a project manager?

Models are for ezpz json to c# data binding.
Largely pointless. Most server-side logic is done in the controller.

controller is middleman for model and view. the model handles data, the view handles pretty gui, the controller handles matching the two together. any request from the view needs to be interpreted in the controller so the model can understand it and give the correct data. think of it as a language translation where the view speaks japanese and the model speaks english, but the controller speaks both.

Why not have everybody speak same language lol?

Definitely C into Java.

node.js would like to have a word with you

project manager dumby

could've meant anything

What do project managers even do?
I knew some people getting interviewed for PM positions at Microsoft straight out of undergrad.
Shouldn't a manager have more industry and business experience?

Shill oop

>undefined reference to gsl_sf_hypergeoU"

Your problem all along is not knowing how to link libraries in GCC? What exactly are you typing into GCC to compile your application with GSL?

strcpy_s((char*)cText, 4, (char*)p4);

cText has 8 elements + null terminator and p4 has 4 elements + null terminator.

i want to get all the elements in p4 except null terminator and put them into the first 4 elements in cText. running the above line doesnt work and gives me an error.

>strcpy_s
>_s
Please no.

Ebin

but microsoft tells me it's SAFE :(

C11 annex K is a fucking joke, and Microsoft can go fuck themselves for shoehorning it into the language.

no one wants to write sql queries just to look at a menu

never mind, i included too many of their header files.

Is there such a program that will go through all of my source files, see what each file is including and generate a Makefile that isn't a retarded mess?

Of course you use for loops and else if statements in operating systems... but the language of choice is typically C or C++. Python would be atrocious.

Yes. What I am talking about in specific, however, are runtime errors. There is no such thing as a runtime type error in C.

Neither C nor C++ has for else

I thought you were referring to them as two different concepts. Honestly... I've never had to use a loop+else combo, and anywhere that it might be more convenient would not be enough to justify the use of Python in a kernel module.

What's the difference between runtime type error and any other runtime error?

It wouldn't be hard to do for else in C.

gcc -M

totally not retarded
seq.o: seq.c /usr/include/stdc-predef.h /usr/include/stdio.h \
/usr/include/features.h /usr/include/sys/cdefs.h \
/usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
/usr/include/gnu/stubs-64.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1/include/stddef.h \
/usr/include/bits/types.h /usr/include/bits/typesizes.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1/include/stdarg.h \
/usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h seq.h
seq.o: seq.h /usr/include/stdc-predef.h

gcc -MM will not output any system headers.
gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html

nice thanks

Anything crucial missing on this keyboard when I want to program?

>using a language that doesn't allow you to define your own control flow structures

Team culture and fit

Hmm, I like that.

Nothing. They were just being used as an example of the myriad of runtime errors that can be tossed around in Python. Python is a dynamic language and has a strong focus on the runtime. C and C++ get most things detected at compile time. Generally speaking, you don't want to go tossing around exceptions in a kernel module, or doing anything that could at all cause a crash.

>download a texture off the internet
>try and include it in a project
>error : missing asset "C:\Users\Silliman\Documents\Tutorials\Textures\Metallic_Texture.png"

ok who the FUCK thought it was a good idea to make assets not have relative paths?
you can't even edit these finished textures in either as far as I can tell

senior software engineering student. I NEED personal projects. I have exactly..zero.

languages:
proficient in -> Java, C
novice in -> Ruby, PHP, Rust
complete noob in -> C++, Python

other:
I also know HTML, CSS, and SQL

any ideas?

inb4 make your own operating system, kernel, design your own relational DBMS, other troll answers

>proficient in Java
There's no hope for you
You only get 1 soul

is the _ like a default in a switch?

Python is pretty easy, though it's not that good. I would suggest you put your efforts on C++, right now.

Yes, exactly
It's a pattern that matches anything

>Python is shit
>Suggests C++
So going from shit to different shit.

Started CS50x, finally going to do it Cred Forums

i don't fucking get this at all. now i get "file not found" except when i right click and select Open #include it will open the file. wtf?

I'm building a webservice for a client and I have the backend going
He wants iOS and android app, I have zero experience in any of those
What's a good and quick way to build something that works on both? Xamarin?

At least C++ is a language for people over the age of 12

And under the age of 14

Not at all

If I nest two for cycles I pretty much select a rectangle
for(int i=50; i

react native

Functional programming is the future. Lower memory cost and increase in threads suits the functional paradigm which is pure.

Best of all we all get to not fuck around with the crappy overcomplicated mess that is OOP programming. If someone just made Monads a bit easier I'd be really happy.

Also I understand Monoids in theory, it's basically a group (Algebra) without the inverse property, I just can't see how that is applied to programming.

>lower memory cost
not in Haskell

>it's basically a group without the inverse property
that's a monoid
monads are a specific kind of monoid

Is there any reason to use Ruby over Python?

for applications of monoids to programming:

a magma has a closed binary operation
you can think of this as any kind of way of combining two pieces of data (that gives back the same type), e.g. adding numbers, appending vectors, combining updates

a semigroup is an associative magma
this means that
a + (b + c) = (a + b) + c
this has a few uses - one is incremental updates
(((a) + b) + c) + d
e.g. saving transaction logs rather than the entire new state
the other is parallelism
(a + b) + (c + d)
run a + b and c + d on seperate threads, then combine the results

a monoid is a semigroup with an identity element
a + 0 = a
0 + a = a
this lets you fold over lists, and can be a sort of empty state

the traditional example of a monoid is a list, where appending is the operation and an empty list is the identity
"" + a = a
a + "" = a
(a + b) + c = a + (b + c)

it looks like monads in a category C are monoid objects in End(C)
the wiki says godement introduced these in his book which i thought i had read carefully; i guess not. i've really never had to use them for anything

you can use them to describe effectful computations in a pure fashion

i'm speaking as a mathematician. i sometimes have to use stacks and topoi and stuff; i thought the 2-category stuff there that was about as exotic as it got

you would think that people in this field would be all over haskell but even the ones who do theoretical computer science are pretty awful at computers in my experience. it's just interesting

I wish i'd done a degree in mathematics or even computer science proper

Category theory is beyond me, other than some of the simplified uses in Haskell

I get it. I really get it. I've worked with group theory and know abstract algebra. I know what a unit/identity element is. I also know associativity and closure.

Working with Integers, lists, etc. That's just natural I don't get what we monoids is supposed to help you understand.

Thanks for the answer though. I appreciate you taking the effort.

Can anyone help me on assembly programming? I need to add two 128 bit signed numbers together, but the word size is 32 bits. wtf do I do. :>

look at the instances of hackage.haskell.org/package/base-4.9.0.0/docs/Data-Monoid.html
for example

i think the problem with category theory is that it's boring. most people need a good reason to wade through the definitions (and it is mostly definitions) and then something interesting to practice them on. just sitting down and reading mac lane cover to cover does not work

always happy to chat about it here. it's not over your head, really

there's always something you wish you had learned earlier. i'm thinking of "getting out" so in the evenings i'm cramming algorithms for whiteboard interviews. many regrets

32 * 4 is 128

"collision detection" makes it sound hard! it's four quick tests. i think whether there's something better depends on what you're actually doing inside the loops

A hacker is someone who enjoys playful cleverness--not necessarily with computers. The programmers in the old MIT free software community of the 60s and 70s referred to themselves as hackers. Around 1980, journalists who discovered the hacker community mistakenly took the term to mean "security breaker."

Please don't spread this mistake. People who break security are "crackers."

>he can't define macros for control flow
>being a filthy blubfag
(defmacro confirm (&body body)
`(prog (input)
start
(princ "Are you sure you wish to do this? Y/N ")
(setf input (read))
(case input
(Y .,body)
(N (princ "Cancelled."))
(T (go start)))))

better
(defmacro confirm (&body body)
`(tagbody
start
(princ "Are you sure you wish to do this? Y/N ")
(case (read)
(Y .,body)
(N (princ "Cancelled."))
(T (go start)))))

white people can't program for shit

>choosing to use macros over regular functions

just doing this and that for learning purposes

where should one get started with hardware
are these meme microcontrollers good

You could go directly the 'hardcore' way and start directly with atmel/pic and C or just go for arduino first.
Arduino is pretty easy to learn and you can do lots of nice stuff with it

C Primer Plus
or
C Programming a modern approach

Do arduino like everybody else. Then gradually work your way out of the atmel/babby IDE setup towards TI's MSP430 platform if you actually want to impress people.

I was able to spin my experience enough to get hired as an electronics technician in a factory. No more open office hellholes, feels fucking great.

If you're

k&r

why are global variables in C set to extern by default?

thanks guys; i'll try it out. it's just for fun really
what sorts of things have you done with it?
what's your opinion on the other options that are really little linux boxes?

In functional programming, how would you say "either a string or an int"?

Its all strings in fp

Maybe type?

If I put a 16-bit int into a register
Then for each 8-bit register it has, I divide by 2, will the whole 16-bit value be divided?

why not put a 16bit int into a register and divide the upper and lower halves by 2 and see if it works

No.

thinking of making an apple newton like PDA using a Cortex M board, wifi module, and a touch screen, it'll have mango reading, erotica reading, maybe pdf reading thru an online pdf to image service, news reading, maybe even a tiny irc client

why?

I feel you. Installing open source Fortran/C/C++ libraries and then actually calling them from any language is a huge PITA.

Hey guys, in Python, how would I convert a string that spans multiple lines like this:

values 1, 2, 3,
4, 5, 6,
7, 8, 9;


to an array [1,2,3,4,5,6,7,8,9], remove 2 and 5, then write it to a file in the same manner:

values 1, 3, 4,
6, 7, 8,
9;

I'm trying to figure out file manipulations.

Now that genymotion is pay to use, which phone emulator people uses?

This. Why would you need macros for this when you have lazy evaluation?

How do i add class in laravel, wtf is this shit

is there any reason for the 2 and the 5, or do you just want those values removed?

generating an abstracted solution for you is impossible if we don't know the underlying logic you're trying to automate.

nox

what would you do if it were on one line?

The string is in a file. I want to read it, remove the values and write the new string into a different file.

Removing 2 and 5 is just a scenario off the top of my head.

If the input string was written in one line, I would want to print the output the same way I described, at most 3 values per line,

The better question would be what is the best way to capture the numbers between the word "values" and ";" ignoring the number of lines on which they are spread out?

I've come to the conclusion that Mathematica is really, really awesome.

>> Prolog tier awesome pattern matching.
>> Extremely concise syntax for when you want to hash function values to make branched recursion palatable.
>> Very good support for both functional and procedural programming.
>> Ridiculously huge standard library of useful functions.
>> Compiled (unlike Matlab, Python), i.e. for-loops are not 100x slower than C.
>> Fizzbuzz is a one-liner.

is there anything wrong with just knowing python if you're a hobbyist and does knowing python make me a programmer?

Wolfram?

Right. Wolfram Mathematica/Wolfram Language.

I used it for Symbolic Computation/Algebraic Computation, shit is crazy.

I'm having trouble understanding X.509, do I need to supply a client certificate in order to verify a server certificate?
I'm trying to write an IRC bot and I want to verify freenode.

My shit code won't even fit here:
ghostbin.com/paste/5ktg7

Read the LKMPG.

It's cool, and great for mathematicians who don't want to use Matlab, but it's also not really a general purpose programming language.

it's pleasant to use. i refuse to do serious mathematical work using something closed-source though. that seems to go against everything we're taught

i hope will stein really gets sage (>python) off the ground now that he's left academia. i would rather feed his ego than stephen wolfram's

What's the state of Haskell FRP libraries at the moment? I used to write Haskell some years back and always thought it would be cool to make a game in it but never got around to attempting it, what are my options right now?

degoes.net/articles/modern-fp-part-2

haskell fags only

...

Higher education everybody.

>(ah yes!! this is my chance to use a smug anime girl!!!!!)

Macros allow for you to wrap any code you want within the control structure you want and operate on the contents of the code freely. While the former might be possible to a limited extent with regular functions, the latter is not, unless you redesign the entire architecture of the code to accommodate the structure you want to operate on as a return value.

new thread when ? :3

Whenever you make one, pussy.

You're boring, you have no ironical intelligence, I can post whatever I want.

Pretty much a non-country.

...

Eh, I just wrote a fairly non-trivial program in Mathematica and Clojure (compute all Dyck paths with a given area below them, apply that to a stat. physics problem I had). The Mathematica solution ended up being both more concise (due to pattern matching, easy hashing) and faster, which spooked me out enough to write that post.

I agree that its scoping rules limit it for large general purpose stuff, but it's still way more useful for general-ish programming than I first gave it credit for. Especially when you go back to it after having played with Haskell and Prolog, so that you are familiar with the techniques you'd use there. It's way more than a simple toolbox for solving equations and plotting.

Eh. It would definitely be nice to have an open source alternative to Mathematica, but I'm really not a big fan of Python as the alternative.

Tbh I'd rather have a language that supports multiple programming paradigms and with a syntax designed from the ground up to be good for mathy stuff. Julia seems really promising, though due to its focus on speed it does have some C-like gotchas.

>Trying to compile podofo on Windows
I JUST WANTED TO CONCATENATE SOME PAGES IN C++

bump, willing to learn another language but want something CLI only

While that might be true, the confirm macro does not do that, so again: what's the point?

look for values to start recording nums into array, when you reach a EOL start at the beginning of the next line

do this until you reach an empty line, at that point just stop looking for nums

then you can go through the list and use something like filter to remove all nums that are not so in [2, 5]

then just write it back, the formatting you can figure out since it only appears you're writing back at max 3 per line should be more or less the reverse of reading it