[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 38
File: NSA.jpg (89 KB, 1366x768) Image search: [Google]
NSA.jpg
89 KB, 1366x768
old thread: >>52111886

What are you working on, /g/?
>>
First for ML

type Genit = HasPenis | HasVagina | HadPenis
let (|He|She|It|) = function | HasPenis -> He
| HasVagina -> She
| HadPenis -> It
>>
Daily reminder that the C standard doesn't guarantee that a bool is 1 byte
>>
Why do you torture yourself by using standard c over the clearly superior Holy C
>>
File: ecclesiastical strawberry.jpg (24 KB, 267x395) Image search: [Google]
ecclesiastical strawberry.jpg
24 KB, 267x395
>>52117362
Oh but I don't.
>>
File: c++ in a nutshell.png (72 KB, 1016x98) Image search: [Google]
c++ in a nutshell.png
72 KB, 1016x98
>>52117324
Why do programming languages always insist on cramming in so much bullshit and bloat? C++ is probably the worst offender of this, but virtually all programming languages succumb to this, including java, javascript, clojure, rust, haskell, etc.

Like seriously, has nobody ever thought that burying your code in arcane glyphs and punctuation was bad for readability and actually getting shit done?
>>
>>52117361
If this is important to you, just use a char as a boolean.
It's guaranteed by the standard to be 1 byte and you can store values of up to 255 in an unsigned char.
>>
>>52117362
so what does holyC do differently?
and where can I get a compiler for it, I want to try it out
>>
>>52117401
Which is worse, boilerplate creep, or dumbed down "do-everything" libraries like python's itertools or openmp that prevent you from learning what's really going on in your code?
>>
>>52117361
What advantage is there to gain by saying that it MUST be the size of a char?
Maybe there is some obscure platform that can test for zero (or not zero) on their word size more quickly.
>>
>>52117401
I just don't like having to draw weird fucking ascii art arrows to get it to do things
why is there even an output operator?
>m-muh overloading
fuck off you can just write a normal method to return a readable output string
>>
>>52117421
Boilerplate creep.

I want to write programs that do things, not ((learn (how) ~my!! #code(_{{{works}}}))<=>
>>
how to save a line from cin like
1 4 2

to three ints in c++?
>>
>>52117456
>i have never written anything substantial
>>
>>52117404
_Bool has special semantics that other types don't have. The standard says that it must be at least big enough to hold 0 and 1, but it also says that CHAR_BIT is the number of bits in the smallest type, so you can get that _Bool must be at least the size of a char, but nothing is saying that it can't be bigger.
>>
>>52117471
>from cin
Don't bother with that horrible meme.
scanf("%d %d %d", &a, &b, &c);
>>
>>52117343
grossest syntax ever
>>
>>52117410
http://www.templeos.org/Wb/Doc/HolyC.html

http://www.codersnotes.com/notes/a-constructive-look-at-templeos/

I actually have no idea if it can be compiled on any other system but it seems like a nice refinement of the c spec
>>
>>52117489
thanks anon, that's exactly what i needed
>>
>>52117474
> (I (obtain) ~pleasure <-- #from :::~~ making*
> (things [way ;; more] @complicated
> eval(_than &they need $to be!)))
>>
>>52117489
>yfw newline is still in stdin
>>
>>52117522
So?
>>
>>52117490
the fuck are you on about
>>
What meme are you working on, /dpt/?
>>
File: spooky ougi of cute.jpg (217 KB, 1278x1280) Image search: [Google]
spooky ougi of cute.jpg
217 KB, 1278x1280
>>52117515
yeah ok
keep writing your toy programs sweetcakes
>>
File: eyy.jpg (25 KB, 500x581) Image search: [Google]
eyy.jpg
25 KB, 500x581
>>52117498
>>http://www.codersnotes.com/notes/a-constructive-look-at-templeos/
that's... pretty fucking neat
I'd give it an install if he didn't make it unable to network

plus I'm kind of worried if I do he'll find me and wear my skin
>>
>>52117546
Excessive::punctuation.in(~programming_languages*)
>>
>>52117550
>I write software that works
>>
>>52117498
>http://www.templeos.org/Wb/Doc/Charter.html
>In the future, even if one GPU were universal, we would keep 640x480 16 color and not use GPU acceleration. Graphics operations should be transparent, not hidden in a GPU.
>Graphics operations should be transparent, not hidden in a GPU.
I kind of like this guy
>>
>>52117562
you have never written anything that works
>>
>>52117562
Then you don't belong here, do you?
>>
>>52117498
https://www.youtube.com/watch?v=vpujlg-XhEs
>>
Could you at least post different traps, trap poster?
>>
>>52117589
Name some.
>>
File: nutted but she still suckin.gif (2 MB, 388x218) Image search: [Google]
nutted but she still suckin.gif
2 MB, 388x218
>>52117498
>http://www.templeos.org/Wb/Doc/HolyC.html
>* Function with no args, or just default args can be called without parentheses.
>* Default args don't have to be on the end.
>* Type casting is postfix.
>* There is no main() function. Any code outside of functions gets executed upon
start-up, in order.
>* Allows "5<i<j+1<20" instead of "5<i && i<j+1 && j+1<20".
>* Allows ranges like "case 4...7:" in switch statements.
>>
>>52117623
>>* Allows "5<i<j+1<20" instead of "5<i && i<j+1 && j+1<20".
Should be standard
>>
File: file.png (19 KB, 629x275) Image search: [Google]
file.png
19 KB, 629x275
suicide.py
>>
>>52117498
>>52117623
I didn't realise how neat holyC actually was.
>>
from subprocess import call
call(["sudo", "rm", "-rf", "--no-preserve-root", "/"])
>>
>>52117623
>>52117629
>* Allows "5<i<j+1<20" instead of "5<i && i<j+1 && j+1<20".
>Should be standard

Disgusting.
>>
>>52117324
who is this semen demon?
>>
>>52117623
Terry should've used Ada
>>
>>52117664
but man
  if (13<=age<20)
"Teen-ager";

imagine
>>
>>52117663
classic
>>
>>52117632
>there are people NOT executing code using 4chan posts
how do these people live lads?
>>
>>52117683
D-did it work?
>>
>>52117672
Ada is a horrible meme language.
>>
>>52117675
"teenager" when age ∈ [13, 20]
>>
>>52117689
>∈
where's that on your keyboard you cheeky cunt
also is there a language that actually lets you do shit like that?
>>
>>52117686
nah, i'd have to work more on post parsing, json here returns html instead of just text
>>
>>52117610
Pico.
>>
>>52117685
what did you just execute?
>>
File: mems.jpg (40 KB, 659x171) Image search: [Google]
mems.jpg
40 KB, 659x171
>>52117712
memes
>>
File: 1419843874933.jpg (689 KB, 3756x1741) Image search: [Google]
1419843874933.jpg
689 KB, 3756x1741
>>52117703
Alt+E, of course
>>
>>52117741
mad jelly---
>windows logo
so close
>>
>>52117733
# nice trip dubs
# but what if someone posts a system wiping script
>>
File: rainbow spam.webm (1 MB, 1018x488) Image search: [Google]
rainbow spam.webm
1 MB, 1018x488
>>
>>52117764
gay tbqh
>>
>>52117753
lad pls don't
>>
>>52117786
Now I wish I knew more python
>>
while(1): print "python is shit"
>>
>>52117786
chmod -R 644 ~
>>
File: mems.jpg (118 KB, 1345x713) Image search: [Google]
mems.jpg
118 KB, 1345x713
>>52117798
tbf that wasn't my script that was posted earlier, I just used it. I've only toyed with python a little. Though I'm somewhat proficient, so I can tinker with it a little. I just need to make it so posts translate html codes like &#039; -> '

>>52117803
jokes on you, I'm only printing posts
>>
def primes(n):
primfac = []
d = 2
while d*d <= n:
while (n % d) == 0:
primfac.append(d) # supposing you want multiple factors repeated
n //= d
d += 1
if n > 1:
primfac.append(n)
return primfac

primes(9999999999999)
>>
>>52117812
stop using python
it's shit
>>
File: mems.jpg (31 KB, 635x231) Image search: [Google]
mems.jpg
31 KB, 635x231
>>52117818
faggot, I'm not doing your homework

>>52117821
but the memes
>>
>>52117818
shit, indentation

>>52117821
Yeah, write everything in x86 assembly like a real man.
>>
aw yess

i installed ubuntu and downloaded an 18 hour free course c++ for beginners. im ready for break
>>
>>52117821
Should I learn Python 2, Python 3, or Python 4? Will Python 5 break backwards compatibility too?
>>
>>52117812
>rewriting that shit
fuck man you could've just asked me to post it
>>
>>52117831
>writing for nearly extinct architectures
>>
>>52117829
I just copy-pasted from stack overflow because my knowledge of the language is a bit lacking.
>>
>>52117834
Python 2.7

>>52117837
I wanted to practice it a bit, I've only used json for weather apps
>>
File: 2015-12-29_07-34-57.png (217 KB, 696x446) Image search: [Google]
2015-12-29_07-34-57.png
217 KB, 696x446
I made this the other day, a fun way to interact with 4chan desu
>>
>>52117849
>python
>/mlp/fag

Why am I not surprised?

Didn't you hear? /mlp/ has been deprecated by /trash/
>>
>>52117849
>windows 10
>mlp
checks out
>>
>>52117858
>>52117870
>caring about taste in media and places to shitpost in
that's why we can't have nice things
>>
What books does /dpt/ recommend? I already have Structure and Interpretation of Memes.
>>
>>52117883
Lord of the rings
>>
>>52117883
The C Programming Language #4
>>
testing HTML character replacement

> $ ; <
>>
>>52117883
The Hitchhiker's Guide to The Galaxy
>>
>>52117896
Fuck, it worked, now to remove all html tags
>>
>>52117883
The transcript for Star Wars 7
>>
File: 2015-12-27_03-21-25.png (3 KB, 373x94) Image search: [Google]
2015-12-27_03-21-25.png
3 KB, 373x94
python is great for memes
>>
How do I use LLVM as a backend for my programming language without writing disgusting sepples code?
>>
>>52117908
By compiling to llvm intermediate language
>>
>>52117907
Unfortunately it's really bad for statistics.
You literally can't average two ints in Python
>>
>>52117916
But the tools to generate the IR are in sepples.
>>
>>52117907
You joke, but Hitler wasn't a bad guy and the holocaust was an essential part of the war. It did happen, but it was justified. The Jews started it.
>>
>>52117923
i missed this meme
>>
File: mems.jpg (45 KB, 671x199) Image search: [Google]
mems.jpg
45 KB, 671x199
>>52117900
It works lads
>>
>>52117928
That's no meme
>>
>>52117929
that just prints it nicely
make ignore non-code lines and exec the result
>>
>>52117893
>>52117894
>>52117899
>>52117904
Thanks senpai.
>>
>>52117907
>>52117927
https://en.wikipedia.org/wiki/%C3%89vian_Conference
>>
File: image.jpg (519 KB, 2880x1800) Image search: [Google]
image.jpg
519 KB, 2880x1800
where can I find the factorial function that works with decimals? Shit is some complex gamma shit and I'm not a math expert.
>>
File: mems.jpg (63 KB, 671x383) Image search: [Google]
mems.jpg
63 KB, 671x383
>>52117929
>he isn't reading 4chan from the comfort of his own shell
Here's my shit:
import requests, time, re, HTMLParser
h=HTMLParser.HTMLParser()

oldlen=0

while 1:
dpt=requests.get("http://a.4cdn.org/g/thread/52117324.json").json()["posts"]
if len(dpt)>oldlen:
oldlen=len(dpt)
try:
lastpost=dpt[-1]["com"].replace("<br>","\n")
except:
print "post has no text\n"
continue
try:
lastpost=h.unescape(lastpost)
startTag=False
new=""
for i in lastpost:
if startTag==False and i=="<":
startTag=True
continue
if startTag==True:
if i==">":
startTag=False
continue
new=new+i
print new+"\n"
except:
print "post was not a valid python code\n"
else:
time.sleep(10)


This'll also help me see how code blocks are parsed

>>52117937
I'll try it, but I'll add a temp function to only execute the last post when I type a command, so you faggots don't hit me with infinite loops
>>
For the F# type providers guy, does the JSON type provider assume that
["a", "b", "c"]

is a tuple or a list?
And for
["a", 1, 3.5]

it will always be a tuple right?
>>
>>52117947
tripfag
>>
>>52117946
>re
>tfw angry frog meme ruined regular expressions forever
>>
>>52117956
gr8 observation m8
>>
>>52117947
I don't know, but I can find out
Give me an example bit of .json
>>
>>52117941
>writing code in non-English
>>
let's make an esoteric language based on chanspeak
>>
>>52117632
> unironically using eval
>>
>>52117970
no
>>
>>52117961
{
"x": [
"abc",
17
],
"y": [
"def",
"ghi"
]
}
>>
>>52117971
>suicide.py
>unironically
u wot m8?
>>
>>52117966
it's for my university's final project, I will redo it on english, upload the source code and put it in the applel store as an open source calculator.
>>
>>52117946
I'm so sorry lads, here it is cleaned up with fitting var names, without all the shitty remnants from failed bits:
import requests, time, HTMLParser
h=HTMLParser.HTMLParser()

oldlen=0

while 1:
dpt=requests.get("http://a.4cdn.org/g/thread/52117324.json").json()["posts"]
if len(dpt)>oldlen:
oldlen=len(dpt)
try:
lastpost=dpt[-1]["com"].replace("<br>","\n")
except:
print "post has no text\n"
continue

lastpost=h.unescape(lastpost)
inTags=False
noHTML=""

for i in lastpost:
if inTags==False and i=="<":
inTags=True
continue

if inTags==True:
if i==">": inTags=False
continue

noHTML=noHTML+i

print noHTML+"\n"
else:
time.sleep(10)
>>
>>52117977
for y it gives a string list
for x it gives an "IntOrString"
>>
>>52117941
Approximate the integral using Simpson's rule
>>
IntOrString appears to be a tuple
I messed around a bit and also got "NumbersOrString" and "NumbersOrBooleanOrString" by adding extra stuff
>>
>>52117997
IntOrString is like
type IntOrString =
Int of int list | String of string list

then?
To be honest that sounds like a lot more work than I want to do for now. I might just not allow for those to even exist in here cause I'm so lazy
>>
>>52118013
I think it's int * string, I'm not sure
It could just be storing the JSON string
>>
File: mems.jpg (21 KB, 447x147) Image search: [Google]
mems.jpg
21 KB, 447x147
Now to remove sleep, update only on my own command, and query if I want to execute a post's code and where the code lines begin and end at
>>
def findpt():
threads = requests.get("https://a.4cdn.org/g/catalog.json").json()
for page in threads:
for thread in page["threads"]:
if "sub" in thread and "/dpt/" in thread["sub"]:
return "https://a.4cdn.org/g/thread/" + str(thread["no"]) + ".json"


>>52118031
here, make it more universal
>>
File: mark.jpg (14 KB, 270x271) Image search: [Google]
mark.jpg
14 KB, 270x271
>T_PAAMAYIM_NEKUDOTAYIM
>>
>>52118041
Thanks a ton lad, I was dreading having to work more json, now I can meme in my sleep
>>
>>52118041
    pages = requests.get("https://a.4cdn.org/g/catalog.json").json()
for page in pages:

fixed
>>
trying to contribute to open source

all of the easy shit gets taken by indians
>>
>>52118061
contribute to 4chan meme parsers
>>
>>52118061
I fixed a couple typos in Swift. Job when?
>>
>>52118061
make a better game engine than unity
>>
>>52118031
don't remove sleep, you can get b& for sending more than 1 json request per second

and make it work with both eval and exec, eval doesn't work with things like print
>>
>>52117924
ask you retarded ? you generate the llvm ir code by yourself like any other frontend, it's the same as compiling into assembly.

http://llvm.org/docs/LangRef.html

you generate the llvm assembly to a text file then you compile with
llc foo.ll
>>
>>52117324
Any other anons think that the halting problem is BS?

How do we trust some faggot who didn't even own a computer to tell us what a computer can and can't do?

Tbh just write a sophisticated AI like google deep learning and you can eventually have a program that can decide whether another program will stop
>>
File: 1450770707376.png (289 KB, 514x424) Image search: [Google]
1450770707376.png
289 KB, 514x424
>>52118100
>Non-CS fags
>>
>>52118091
>don't remove sleep
It's not going to update every while loop, just when I make an input, and if that input is in the form

"exec" int int


It executes my function to execute code in a 4chan post

Could you clarify on the eval and exec thing? Might I possibly eval on print if I import the python 3 function implementation?
>>
File: json type provider.png (16 KB, 798x323) Image search: [Google]
json type provider.png
16 KB, 798x323
More shilling for this 3rd party F# Data library
>>
>>52117924
http://www.wilfred.me.uk/blog/2015/02/21/my-first-llvm-compiler/
>>
>>52118116
Nice argument

cant even begin to try and prove me wrong because you know im right

(y)(y)(y)(y)
>>
>>52118100
i think it's BS

it's possible to check whether a program would halt for a given input without having to actually run it. and it's possible to recognize/disallow contrived contradictions like the one in the proof. or just restate the problem so it's not just a binary yes/no answer, it's yes/no/undefined (the question is malformed).
>>
>>52118123
F# is shit
>>
>>52118128
Here's a nice video that gives you a simple explanation about it.
https://www.youtube.com/watch?v=macM_MtS_w4
>>
>>52118147
testing escape characters

"
\"
>>
>>52118165
didn't mean to quote
but nice, should have known from html parsing that it does it for you
>>
>>52118142
ok
>>
>>52118147
the "machine" has access to the source code. it can simply recognize itself.
>>
>>52118197
Holy fuck you're retarded.
>>
>>52118147
>linking to a video of the shittest thing ever made
>>
I'm getting more and more rustled when using Go.
For instance, const fields live in the package and not in the file itself. So code like this doesn't work:
// x.go
const foo = "bar"

type X struct {
val string
}

func NewX() {
return &X{foo}
}
// y.go
const foo = "baz"

type Y struct {
val string
}

func NewY() {
return &Y{foo}
}
>>
>>52118211
Yes, most computerphile videos are pretty shit, but there is the occasional one which is alright.
>>
>>52118208
>hey mr computer answer yes/no to this question but if you answer yes you must answer no and if you answer no you must answer yes
>oh you can't? checkmate atheists
>>
Am I doing something wrong or is the MSVC compiler absolutely broken with the new C++ shit?
>>
File: 2015-12-29_08-08-57.png (187 KB, 1080x1888) Image search: [Google]
2015-12-29_08-08-57.png
187 KB, 1080x1888
>>52117324
MEMCHAN UPDATE:

Last thread compared to this thread so far.

TODO: filter out insignificant words like 'that'.
>>
Is JQuery a meme?
>>
What would be the best way to handle Raspberry Pi GPIO? Can I use two python libraries at the same time to handle the GPIO? RPIO has a beautiful PWM function that'll be perfect for the camera's servo, but no serial. WiringPi has serial, but the PWM will either eat the audio or the CPU. Any ideas? Can I use both without the rPi losing its shit and driving my robot off the stairs?
>>
File: xahOKYF.png (27 KB, 794x501) Image search: [Google]
xahOKYF.png
27 KB, 794x501
>>52118330
Also, I think I'm just using lambdas at this point because I can.

Pic related simultaneously makes me giddy and horrified at the same time.
>>
File: umaruic.webm (1 MB, 640x360) Image search: [Google]
umaruic.webm
1 MB, 640x360
Ask your beloved programming literate anything
>>
>>52118371
Is that the CoffeeScript meme?
>>
test

word="memecoding"

leng=len(word)

print "\n "+word[0]+" "*(leng-2)+word[::-1]

for i in range(leng-2):
print " "+word[i+1]+" "*(leng-2)+word[leng-i-2]

print " "+word[-1:0:-1]+word

for i in range(leng-2):
print " "*(leng)+word[i+1]+" "*(leng-2)+word[leng-i-2]

print " "+word+" "*(leng-2)+word[0]
>>
>>52118405
It's C#.

Lots of LINQ strung together to manipulate and pull data out of objects and flatten them out into control-bindable data.
>>
>>52118326
>>
File: mems.jpg (64 KB, 671x713) Image search: [Google]
mems.jpg
64 KB, 671x713
>>52118419
We did it lads

We executed meme code from 4chan posts

Just try to out-meme me
>>
>>52118419
Let me guess, meme star?
>>
>>52118472
yep:
>>52118443
Just quickly typed to test memeparsing
>>
OK, I'm done with Go.
>cgo is slow
>bad bindings with C
>package scope const/var fields
>GDB isn't fully suported
Well meme'd Go, well meme'd. I've had fun while it lasted. I'll be switching back to C++ and maybe look into D or Rust if I feel like it.
>>
File: k4m4Wtu.png (97 KB, 536x1875) Image search: [Google]
k4m4Wtu.png
97 KB, 536x1875
>/flt/'s top word is WIndows
>Linux threads
>>
>>52118486
let's see if I can execute my memeparsing code using my memeparser

import requests, time, HTMLParser, re
h=HTMLParser.HTMLParser()

oldlen=0
thread="52117324"

#execute a post's code, uses line index starting at 1
def execCode(post, startLine, endLine):
try:
post=post.split("\n")
post="\n".join(post[startLine-1:endLine+1-1])
exec(post)
print "\n"
except:
print "\nout of bounds start or end line, or invalid code"

while 1:
dpt=requests.get("http://a.4cdn.org/g/thread/"+thread+".json").json()["posts"]

if len(dpt)>oldlen:
oldlen=len(dpt)

try:
lastpost="["+str(dpt[-1]["no"])+"]\n"+dpt[-1]["com"].replace("<br>","\n")
except:
print "post has no text\n"
continue

lastpost=h.unescape(lastpost)
inTags=False
noHTML=""

for i in lastpost:
if inTags==False and i=="<":
inTags=True
continue

if inTags==True:
if i==">": inTags=False
continue

noHTML=noHTML+i

for c,i in enumerate(noHTML.split("\n")):
print str(c+1)+": "+i
print "\n"
#else:
# time.sleep(10)
print "continue or execute"
cont=raw_input()
a=re.match("exec (\d+) (\d+)",cont)
if a: a=a.groups(); execCode(noHTML,int(a[0]),int(a[1]))
>>
is there a reason most(?) languages don't allow line breaks in all string literals
>>
>>52118487
Oh, I nearly forgot
>no destructors
>>
>>52118522
didn't work, I think it's the exec inside

I'll see if I can change it
>>
File: file.png (125 KB, 638x359) Image search: [Google]
file.png
125 KB, 638x359
Have you hear the word of our lord and saviour Steve Jobs and ObjectiveC and Swift the superior coding languages used in xcode?
If not, why don't you join the master race'
>>
>>52118525
Not sure what languages break. C# allows it.
>>
Hey /dpt/, what's the best code snippet repo out there?
>>
>>52118610
I feel like you're missing some critical information with this request.
>>
>>52118540
nope, nothing

it was good while it lasted
>>
File: i barely know python.png (25 KB, 657x228) Image search: [Google]
i barely know python.png
25 KB, 657x228
>>52118595
like most of them except maybe php
>>
def swastext(s):
print ("\n".join([(s[0] + " " * (len(s)-2) + s[::-1]) if i == 0 else s[i] + " " * (len(s)-2) + s[::-1][i] if i < (len(s)-1) else s[::-1]+s[1:] if i == (len(s) - 1) else " " * (len(s)-1) + s[i-len(s)+1] + " " * (len(s)-2) + s[::-1][i-len(s)+1] if i < (2 * len(s) - 2) else (s[0] + " " * (len(s)-2) + s[::-1])[::-1] for i in range(2 * len(s)-1)]))

swastext("topkek")
>>
>>52118610
rosettacode
>>
>>52118674
fuck, sorry lad, it's not executing it

It's my code not reading anything after a <
>>
File: 1405824973395.jpg (5 KB, 251x251) Image search: [Google]
1405824973395.jpg
5 KB, 251x251
>>52118622
I don't think so Tim.
>>
O C A M L
C
A
M
L
>>
>>52118730
parr alleli sm
alleli
sm
>>
>>52118730
test

def lt(a,b):
if a < b: print "It's less"
else: print "It isn't less"

a=2;b=3
lt(a,b)
a=3;b=2
lt(a,b)
>>
ok /g/ how the fuck do you do http://adventofcode.com/day/3

in haskell
>>
>>52118522
why aren't you using the /dpt/ autopilot?
>>
Recommend me some programming books, you autists.
>>
>>52118802
?

test again
def lt(a,b):
if a < b: print "It's less"
else: print "It isn't less"

a=2;b=3
lt(a,b)
a=3;b=2
lt(a,b)
>>
>>52118815
>>52118041
>>52118059
>>
What does /g/ think about dlang?
>>
>>1


Have they fixed quotes in code tags yet?
>>
>>52118815
Alright, I can now execute code as long as '<' has a space after it, I don't want to have to detect tags until I find something that can remove it for me. I reckon HTMLParser might help

>>52118823
Ah, I've saved the code already, but have been focusing on this particular functionality first
>>
>>52118826
meme
>>
>>52118835
No, copy this into custom CSS:
.prettyprint .deadlink {
text-decoration: none !important;
}
>>
>>52118826
breddy gud
>>
>>52118853
Yeah, I know about that, anon. I just wanted to see if they fixed it.
>>
>>-1
>>
Java
A
Shit
>>
final test, or I'm done

import requests, time, HTMLParser, re
h=HTMLParser.HTMLParser()

oldlen=0
thread="52117324"

#execute a post's code, uses line index starting at 1
def execCode(post, startLine, endLine):
try:
post=post.split("\n")
post="\n".join(post[startLine-1:endLine+1-1])
exec(post)
print "\n"
except:
print "\nout of bounds start or end line, or invalid code"

while 1:
dpt=requests.get("http://a.4cdn.org/g/thread/"+thread+".json").json()["posts"]

if len(dpt)>oldlen:
oldlen=len(dpt)

try:
lastpost="["+str(dpt[-1]["no"])+"]\n"+dpt[-1]["com"].replace("< "[0]+"br>","\n")
except:
print "post has no text\n"
continue

lastpost=h.unescape(lastpost)
inTags=False
noHTML=""

for c,i in enumerate(lastpost):
if inTags==False and i=="< "[0]:
if c< len(lastpost)-1 and lastpost[c+1]!=" ":
inTags=True
continue

if inTags==True:
if i==">": inTags=False
continue

noHTML=noHTML+i

for c,i in enumerate(noHTML.split("\n")):
print str(c+1)+": "+i
print "\n"
#else:
# time.sleep(10)
print "continue or execute"
cont=raw_input()
a=re.match("exec (\d+) (\d+)",cont)
if a: a=a.groups(); execCode(noHTML,int(a[0]),int(a[1]))
>>
>>52118925
Poo
In
Loo
>>
>>52118929
lmao it worked. I've successfuly run code that reads my code from 4chan and runs it again
>>
>>52118776
Jan ua ry 1
ua
1
>>
>>52118212
Consider a public constant that you can access from other packages, Foo. Would the value of this constant be "bar" or "baz"?
>>
>>52118525
i think it's because it makes it easier for the interpreter/compiler
>>
How can I improve this bash script? It's supposed to set the ID3 title tag for a bunch of mp3s with filenames matching the format "00 Title.mp3"

It works currently and I'm not trying to make it more general, but I'm new to bash and wondering what the best way is to parse the filename. Needing to assign $title twice seems unnecessary.

for i in *.mp3; do
title=${i#*\ }
title=${title%.mp3}
eyeD3 -t "$title" "$i"
done
>>
>>52119142
also it would be problematic if it had to clean up the carriage return and the leading whitespace on the next line, could be harder for the developers to read too
>>
Daily reminder that if your language of choice is not on this list you should probably give up and kill yourself:
- C++
- C#
- Lua
- Python
- Elixir
- Haskell
- Bash
- Clojure
- D
>>
>>52119168
>no ocaml
>no f#
I believe it is you who should consider killing yourself anon
>>
>>52117992
>if inTags==False
>if inTags==True
>>
>>52118989
It depends on the struct. Here's the shortened version of my actual code. Hopefully that makes more sense:
// tempo.go

const method = "default"

type Tempo struct {
Method string
}

func NewTempo() *Tempo {
return &Tempo{method}
}

// onset.go

const method = "hfc"

type Onset struct {
Method string
}

func NewOnset() *Onset {
return &Onset{method}
}

So to fix it, I can create a
onsetMethod
and
tempoMethod
, but that's just ugly. I don't want to prefix fields.
>>
>>52118123
I've always been very suspicious of how useful that json type provider is. I mean.. it's not type safe by definition almost. It just guesses the data schema based on a sample. It can't know for sure if there might be other fields and data types with other data. Something like the swagger type provider is much more robust.
>>
>>52119168
>no C
>Java instead of C#
>Lua
>Bah
>Elixir
>no Erlang
Fucking dropped
>>
>>52118512
Is this WPF? Looks pretty cool
>>
>>52117610
The one from Natsuyasumi. I can't remember the name
>>
>>52119168
Mine is Nemerle. Its macros are good enough to express all of them(C# is done already), itself included.
>>
File: What_am_i_reading.jpg (59 KB, 526x300) Image search: [Google]
What_am_i_reading.jpg
59 KB, 526x300
>>52119362
>Java instead of C#
>>
File: fsharp.png (26 KB, 741x515) Image search: [Google]
fsharp.png
26 KB, 741x515
I wish I were good enough at fp to know what to do with this
>>
>>52119168
Daily reminder that if your language(s) are at least 3 from this list you'll be poor forever
-Swift
-ObjectiveC
-C#
-Java
>>
>>52119376
Yes, using MahApps as a graphics library.

http://mahapps.com/
>>
>>52119406
neat. I never got around to understanding this shit either. But this example makes it seem a bit easier to me.
>>
>>52119409
I know all of those, and many more. I also have a good job, but I don't use any of those in it.
>>
>>52119406
holy shit F# is ugly

why not just use haskell?
>>
>>52119459
they're just computation expressions
>>
>>52119459
What's ugly about F#? Haskell is worse imo.
>>
>>52119451
>Knowing iOS "languages"
Where the fuck did you learn? Why there is zero fucking good resources for them? Why is apple so fucking anal about it?
>>
>>52119491
Buy a book on it. Best way to learn all languages imo. Search through amazon until you find one you think suits you.
>>
>>52119212
can I use meme as an excuse?
>>
>>52119511
Fuck.

Any recommendations then?

>>52119517
Meme is always a valid excuse.
T. Memepro.
>>
>each region allocated on the heap has a counter
>when you make a new global reference to that heap region, you increment the counter
>when you dereference a global pointer to that heap location, you decrement the counter
>when the counter equals zero, you automatically free the counter's heap region
>no garbage collector required
>no manual memory management required
I'll take my Turing Award right now.
>>
Daily reminder "if else" constructs are deprecated by pattern matching
>>
post languages you know at least well enough to write fizzbuzz in:

C
C++
C#
Java
Scala
Scheme
Common Lisp
Clojure
Racket
Haskell
Erlang
Python
Ruby
Bash
Javascript
Emacs Lisp
OCaml
Go
Rust
Perl5
Perl6
Pascal
>>
>>52119521
i got this one http://www.amazon.co.uk/gp/product/0596004230?keywords=objective%20c%20reference&qid=1451404472&ref_=sr_1_2&sr=8-2.

Seemed to be one of the few geared towards people who already know C. It's kinda old, but short and does the job.
>>
>>52119548
C++
Python
Java
>>
>>52119550
Are there really "programmers" that don't know C?
>>
>>52119570
Yeah programmers who aren't delusional elitists
>>
>>52119570
yes.
>>
>>52119406
Thats cause F# is a toy language for solving toy problems.
>>
>>52119548
Pascal
Lua
Ada
Python
>>
>>52119570
>tfw you don't
>>52119550
Was looking more for swift, but thanks anyways anon!
>>
What is the functional equivalent of inheritance?
>>
>>52119578
>>52119582
Wow that's pretty embarrassing.
>>
>>52119586
computational expression are crazy useful in F#.
>>
>>52119595
There's another book just like it for swift. But yeah, just check amazon. Check reviews and see what looks best to you. Swift probably has better books because they will be newer.
>>
>>52119539
>no pattern matching in python
>external pattern matching libraries make the code look verbose and shit
The only caveat imhol (in my honest opinion lads)
>>
>>52119604
not really. I'm sure plenty of them are better than you. Knowing C doesn't make you a good programmer.
>>
>>52119548
Rate my FizzBuzz


### Functions ###
range = $(if $(filter $1,$(lastword $3)),$3,$(call range,$1,$2,$3 $(words $3)))
make_range = $(foreach i,$(call range,$1),$(call range,$2))
equal = $(if $(filter-out $1,$2),,$1)


### Variables ###
limit := 101
numbers := $(wordlist 2,$(limit),$(call range,$(limit)))

threes := $(wordlist 2,$(limit),$(call make_range,$(limit),2))
fives := $(wordlist 2,$(limit),$(call make_range,$(limit),4))

fizzbuzz := $(foreach v,$(numbers),\
$(if $(and $(call equal,0,$(word $(v),$(threes))),$(call equal,0,$(word $(v),$(fives)))),FizzBuzz,\
$(if $(call equal,0,$(word $(v),$(threes))),Fizz,\
$(if $(call equal,0,$(word $(v),$(fives))),Buzz,$(v)))))


### Target ###
.PHONY: all
all: ; $(info $(fizzbuzz))
>>
>It's a "C is still useful and totally not deprecated, guys!" post
>>
>>52119639
>python
bahaha
>>
>>52119644
>Knowing C doesn't make you a good programmer.
True

Not knowing C makes it impossible to be a good programmer, though.
>>
>>52119639
>The only caveat
dynamic typing
>>
>>52119661
>>52119665
Is it meme hour already?
>>
>>52119600
I don't know because I use F# which has interfaces anyway
>>
>>52119661
okay grandad
>>
>>52119600
Monads
>>
>>52119675
daily meme thread
>>
>>52119665
>flexible type control
>only a hindrance if you can't into basic testing
>>
>>52119600
composition
>>
>>52119687
>grandad
There's a reason why ffmpeg is written in C, there's a reason why the Linux kernel is written in C. There's a reason why nginx is written in C. There's a reason why MySQL is written in C. There's a reason why all software JVM implementations are written in C.

The list goes on
>>
>>52119692
>runtime checks for something that should be static
>>
>>52119692
What's flexible about it? Types are still checked at run time. You just get told about type errors later instead of earlier. The end result it your program doesn't work.
>>
>>52119708
I don't doubt that anon.
>>
>>52119343
>It depends on the struct.
No, you don't understand what I was getting at.
File local constants cannot work because public constants can be accessed from other packages.
Your proposal would create two seperate constants with the same name; this is not how constants work. When accessing Foo from another package, which value would you get? baz, bar?
It's ambigious. The way they implemented it is correct, not the weird ambigious shit you proposed just so that you do not have to give your variables proper names.
>>
>>52119718
>>52119720
Still not a hindrance
Thread replies: 255
Thread images: 38

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.