[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: 27
File: K&R himegoto.jpg (159 KB, 500x700) Image search: [Google]
K&R himegoto.jpg
159 KB, 500x700
old thread: >>51970377

What are you working on, /g/?
>>
what are some cool algorithms/data structures to implement. Coolness over function.
>>
>>51974909
Averaging two ints is a good one.
>>
sixth for semantic highlighting
>>
>>51974909
Fibonacci heap but they are usable

Quadtrees for level of detail

Both usable though
>>
>>51974909
singly linked list stack!
void stack_push(stack_t *stk, int data)
{
frame_t *frame = (frame_t *) malloc(sizeof(frame_t));
frame->data = data;
frame->next = stk->head;
stk->head = frame;
stk->size += 1;
}

int stack_pop(stack_t *stk)
{
if (stk->head == NULL)
printf("Stack empty.\n");
frame_t *frame = stk->head;
int data = frame->data;
stk->head = frame->next;
stk->size -= 1;
free(frame);
return data;
}
>>
>>51974919
why is this a meeem
>>
>>51974944
Because it sounds really easy but is extremely complex.
>>
>>51974909
How difficult? Merge sort, red-black tree, etc
look through CLRS for something that catches your fancy

>>51974943
>guaranteed replies
>>
>>51974909
Stacks
>>51974919
double avg(int a, int b)
{
return a / 2 + b / 2 + (a & 1 ? 0.5 : 0) + (b & 1 ? 0.5 : 0);
}


Parenthesis for readability
>>
>>51974919
Inting two averages in asm
>>
>>51974943
This shit is so fucking wrong, I will assume it's trolling and will simply not reply.
>>
>>51974966
You replied
>>
>>51974966
what's wrong with it?
why does everyone keep claiming it's a troll?
>>
>>51974966
He's been memeing for a couple of days now.
>>
>>51974975
>>51974943
samefag
>>
File: c2w.png (152 KB, 1920x1080) Image search: [Google]
c2w.png
152 KB, 1920x1080
Camera to world
>>
>>51974816
Anon making a game with SFML: did you write your own object/tick layer?
>>
>>>/sci/7734467

>tfw /sci/ bested /g/
>>
>>51974975
He asked how to fix pop, was told how, still posts the one that frees NULL
>>
>>51974943
>NULL
>>
>>51975002
>unironically using C++
>>
>>51974982
World to screen*
Damn it.
>>
>>51975010
#undef NULL
#define NULL 69

// later...

void faggotAnonUsesAPointer(Dick* dickPtr) {
if (dickPtr != NULL) {
printf("%d\b", dickPtr->length);
}
}
>>
Also, any reason to use A* algorithm instead of Dijkstra's algorigth in small search grids?
I can't find any reason to switch.
>>
I just woke up but I couldve sworn I saw this thread yesterday...
>>
>>51975083
If you redefine NULL you're a fucking retard
>>
>>51975089
Dijkstra is just a special case of A* with no heuristic.
>>
>>51975107
Right, thanks. I don't really have a use of heuristics yet. But thanks for the answer, in case I do need it in the future.
>>
>>51975089
No, you won't find noticeable gains in a small search space. I wrote A* and it searched a 200x200 unit grid from the bottom left to the top right in 0.003 seconds; imagine that versus Dijkstra in a small space.

The units aren't precisely defined but the grid was huge, personal testimony.
>>
I have two python questions,
Why the hell does
oct(198)
output 0o306? Why would they put an 'o' instead of zero?
--
I don't know how to describe it well but how do I efficiently do a 'Caesar Cipher', not changing the position but something like... This to This
>>
File: Untitled.png (8 KB, 314x216) Image search: [Google]
Untitled.png
8 KB, 314x216
>>51975135
I didn't know they filtered that stuff..
hmm
>>
So my flesch-kincaid program is way off, probably due to sentence count. It said A Tale of Two Cities was at the level of a 5.57th grader.

>>51975135
1) write a wrapper for oct()
2) idk
>>
>>51975128
Yeah, thanks. Dijkstra will do unitl I need to use Recast/Detour for the larger meshes of land.
>>
File: advent tree.jpg (124 KB, 697x647) Image search: [Google]
advent tree.jpg
124 KB, 697x647
74th place today lads. Could've been much higher if I wasn't fucking about in places. Got the fighting function correct 1st time at least
>>
>>51975135
0o is the prefix for an octal literal. 013 is reasonably the same thing as 13 so they chose a more distinct prefix than just 0.

>Caesar Cipher
Write a map
>>
>>51975135
>0o306
You mean instead of 0306? First one just looks better imo
>>
>>51975135
pretty sure to show which base it is, because 0xF is 15 in hex. I'm probably wrong though.
>>
File: Untitled.png (37 KB, 685x722) Image search: [Google]
Untitled.png
37 KB, 685x722
>>51975160
>>51975163
It's not a valid URL with the letter o
>>
>>51975150
>1) write a wrapper for oct()
What is the formula to convert to octet?
>>
>>51974949
how is (a + b) / 2 extremely complex?
>>
>>51975221
>overflow
>>
>>51975221
That overflows
>>
>>51975180
>It's not a valid URL with the letter o
According to who? URLs can be any numbers and letters in any order.
>>
>>51975211
>like this?
Well, I am trying to obscure URLS and if you use something like http://www.fileformat.info/info/unicode/block/mathematical_alphanumeric_symbols/utf8test.htm
you can still get past 'spam filters' or whatever you need to obscure them for and still have a valid URL
>>
>>51974888
Working on the "while challenge" that I just made up, which means that all if- and ternary-statements, for loops, and any other conditional is prohibited, but gotos, recursion, and while loops are usable.
#include <stdio.h>

int main () {
int i = 1;
while (i < 101 ) {
while (i % 5 == 0) {
printf("Buzz");
break;
}

while (i % 3 == 0) {
printf("Fizz");
break;
}
while (i % 3 && i % 5) {
printf("%d", i);
break;
}
printf("\n");
++i;
}
return 0;
}
>>
>>51975211
>>51975112
What's going on here? Stop deleting these. These are quality posts you loser.
>>
>>51975247
>literally just replacing every if with a while and break
nice challenge
>>
>>51975232
http://0o306.4605307/
http://00306.4605307/
Which one works?
>>
>>51975247
can you make it the goto challenge instead
>>
>>51975261
idk m8, it can't possibly be the pictures
>>
>>51975272
The pictures are on topic.
>>
>>51975272
it's the pictures
the last one was a foot fetish 2hu pic
i don't get why it matters tho
>>
people's champions = gods
>>
Day 21 solutions:
w=[[8,4,0],[10,5,0],[25,6,0],[40,7,0],[74,8,0]]

a=[[0,0,0],[13,0,1],[31,0,2],[53,0,3],[75,0,4],[102,0,5]]

r=[[0,0,0],[0,0,0],
[25,1,0],[50,2,0],[100,3,0],
[20,0,1],[40,0,2],[80,0,3]]

def fight(myDam, myArm):
turn=1
myHP=100
hisHP=104
hisDam=8
hisArm=1

while True:
if turn==1:
hisHP-=max(myDam-hisArm,1)
elif turn==0:
myHP-=max(hisDam-myArm,1)
turn=1-turn
if min(hisHP,myHP)<=0:
return hisHP<=0

minCost=9999
maxCost=0

for i in range(len(w)):
for j in range(len(a)):
for k in range(len(r)):
for l in range(len(r)):
if k!=l:
currCost=w[i][0]+a[j][0]+r[k][0]+r[l][0]
currDam=w[i][1]+r[k][1]+r[l][1]
currArm=a[j][2]+r[k][2]+r[l][2]

if fight(currDam, currArm):
minCost=min(minCost,currCost)
else:
maxCost=max(maxCost,currCost)


print minCost
print maxCost


pls b gentle
>>
>>51975272
Anime pictures, even sexy (non-nude) ones were never considered as the reason to delete a post as long as the body was on-topic. Same for Stallman images.
>>
>>51975083
Undefined behaviour (assuming you included a header which will define NULL, e.g. stdio.h)
>>
>>51974993
kys
they don't even like you there, you fucking retard
>>
There was no need to delete the 2hu images, they weren't even NSFW.

I wish mods would leave us be.

smdh
>>
so how do you add 2 same-signed numbers without overflow
>>
>>51975364
Don't use outdated languages like C where you have to worry about this tripe.
>>
>>51975311
shut the fuck up fgt
>>
>>51975364
Just use a ulong!
>>
>>51975374
All languages have this problem anon.

>>51975364
You make a check before you add them.
>>
>>51975374
>going up higher on the abstraction ladder means numbers work differently on the same architecture
>>
>>51975388
>>51975394
Caught two fish. I'll eat well tonight.
>>
project idea
>>
>>51975402
stay in your phone threads idiot
>>
>>51975405
OS
>>
I have nothing to do and I've landed an internship so I don't care about building my resume with some toy project right now. Should I learn Haskell? I've toyed with it and it looks really fun.
>>
>>51975405
waifu that monitors your internet activities
>>
>>51975421
You mean Cortana?
>>
>>51975418
too hard

>>51975421
possible, monitors what exactly?

>>51975429
he said waifu, and also
>windows
>>
>>51975437
>not getting the joke
>>
>>51975446
funny telemetry meme good work
>>
>>51975229
>>51975230
What does that mean?
>>
>>51975429
Not another apple shit clone, I want a real waifu that monitors me.

>why aren't you programming anon?
>hey! don't touch me there *blushes while her panties are showing*
>It's time to sleep anonsama!
>Do you want me to compile your programs anon~ [Yes] [No]
>W-What are you doing on these naughty websites a-anon? *emabrashed-jelly face*
>You forgot a semicolon in your new program! Don't worry! I can insert it for you :3 [Yes] [No]
>Debian has some new updates! I am downloading them for you~
>>
>>51975463
you have 8 bytes to work with
imagine adding
0x7FFFFFF6 + 0x7FFFFFF3
what happens
>>
Any good Java x libgdx tuts out there? specifically for game development
>>
>>51975470
gayest shit I've ever read
>>
File: 1410447874989.jpg (18 KB, 241x228) Image search: [Google]
1410447874989.jpg
18 KB, 241x228
>>51975473
>>
>>51975475
>tuts
>game devemlopment
>java
fucking typical
kill yourself

>>51975470
>embrashed
>:3
>automatically installing updates
you too
>>
>>51975473
0xFFFFFFE9?
>>
>>51975503
guess what's bigger than MAX_INT
that is
hence, overflow
>>
>>51975437
>OS is too hard
>wants to make a waifu AI when real AIs don't actually exist and all he'll come up with is some sort of state machine
L M A O
>>
>>51975530
You are a state machine too you know.
>>
>http://0306.4605307/%73%65%61%72%63%68?q=rick.amigo&btnI
>>
>>51975530
>AI
>real AIs don't actually exist
1) putting words in my mouth
2) you sure know a lot of what you're talking about
>>
>>51975517
But in JavaScript if you go over the maximum allowed integer it automatically converts it into "Infinity" for you, what shitty language are you using, anon?
>>
>>51975419
Yes.
>>
>>51975572
the original meme is doing it in C, >>51974919 seems to have left that detail out
>>
>>51975585
What can I use it for?
>>
>>51975598
memes
>>
>>51975135
Well, I used
.replace("o", "")
for my first question...
http://stackoverflow.com/questions/14424500/text-shift-function-in-python
something like that is what I'm looking for on the 2nd question
Only I want to convert to unicode characters..
I don't know how to apply this...
>>
>>51975572
>instead of a number you get some string "inf"
go ahead program your rocket in javascript moran
totally safe
>>
>>51975612
>he doesn't know about IEEE infinity
I bet you don't know what NaN is either you dumb caveman
>>
>>51975619
i fucked ur NaN
>>
What if a compiler/interpreter/etc worked using NLP instead of concrete syntax? It would compile horribly slow, but I think it would be cool. For example, there would be no concrete syntax for assignment, but all of these work:

A is an integer.
Move the value 5 into A.
A is now 10.
Assign A to the number three.
Make A 120.

?
I don't know shit about NLP or compilers but this seems feasible, even if horribly impractical.
>>
>>51975490
Sad anon. Still getting bullied at the office?. Or have you still not made it out of your moms dusty trailer
>>
>>51975470
>emabrashed
how do you fuck up this badly?
>>
>>51975662
Which one of the anons I replied to are you? I'm a uni student btw, so neither I suppose
>>
>AI means it behaves and thinks like a human
>an AI is a program or robot that behaves and thinks like a human
>one day there will be real AIs
does this usage of the term 'AI' trigger anyone else
>>
File: whathappened.webm (1 MB, 640x640) Image search: [Google]
whathappened.webm
1 MB, 640x640
Ask your beloved programming literate anything.
>>
>>51975829
How should it be used?
>>
File: 1441263131722.jpg (375 KB, 1280x720) Image search: [Google]
1441263131722.jpg
375 KB, 1280x720
Even the Hidamaris know best compiler.
>>
>>51975843
AI = artificial intelligence
"This program uses AI to do X"
"The AI for the NPCs in this game are great"
"He's been working in the field studying AI"

AI != something with AI, e.g. the program that uses/has AI

It's entirely autistic of me but I am autistic
When referring to a program that uses NLP and responds relatively human-like to text:
"This is an AI with good conversational skills" vs "This program has AI with/for good conversational skills"

>this is an artificial intelligen(ce|t) [agent]
People say AI when they really mean agent.
>>
>>51975866
>kaaaaaaaaaaaaaan
>somehow clang
why not クレーング
>>
>>51975843
An intelligent agent behaves rationally. There is no description of at what level of functionality the agent must perform. An example is a tic-tac-toe player that uses minimax to always tie games—it is rational and not very complex.
>>
>>51975895
>somehow clang
>why not クレーング
Because you're doing it in reverse.
>>
>>51975843
>>51975885

I clearly misunderstood what was triggering you in >>51975903
>>
>>51975903
This too -- I was mostly bothered by >>51975530, "real AIs don't actually exist" as if the definition of AI hasn't been receding as more people say "That isn't intelligence, that's just computation."
No shit, intelligence is emergent from computation.
Then there's the branch (which overlaps with ^) that defines AI in terms of cognition rather than behavior - thinking like a human rather than acting like one.
They don't even know that loads of industries use AI in some place in their work.
Most of the people that distinguish "real AIs" from AI are just referring to general AI, because expert systems just ARENT enough

>>51975906
What? clang is the original name, not カーン. What am I doing in reverse?
>>
File: mind_is_not_rational-3.jpg (33 KB, 720x1002) Image search: [Google]
mind_is_not_rational-3.jpg
33 KB, 720x1002
>>51975903
this topic reminds me of GEB.
>>
>>51976021
egyptian god, SMITE character, browser automation program...?
>>
>>51975962
"Real AIs" as in what everyone means when mentioning AIs: human-tier intelligence.

What we have now is machine learning which is just calculating derivatives on data and polynomial regression.

If we use my definition of "Real AIs" and your claim that AI is close but not quit there yet. Then AIs dont fucking exist yet.
>>
>>51976042
>if we use my definition
nice
real AI has been used for years
>>
>>51976042
>what we have now is machine learning which is just calculating derivatives on data and polynomial regression
>REAL AI WILL ACTUALLY THINK WITHOUT MATH
watch more syfy
>>
File: myvideo.webm (478 KB, 1920x1080) Image search: [Google]
myvideo.webm
478 KB, 1920x1080
unicode = kill
wat do
>>
Why is JavaScript so fucking weird and hard and insane, closures and callbacks and hoisting and other bullshit. Am I just a total pleb or is JS really a freaky mutant abomination of a language
>>
>>51976119
a mix of both, but you're only a pleb for trying to use js in the first place
>>
>>51976111
Kill self clearly
>>
>>51976111
>Omegle
>ABP
>W8
>Firefox

This is the caliber of people in these threads
>>
>>51976146
nothing wrong with any of these
>>
>>51976159
b8
>>
>>51976041
book
>>
Any Swift programmers in here?

How do I add a unix executable to a project in Xcode and then use it?
>>
>>51976119
>closures, hoisting
If you take the time to learn how they work instead of complaining then you will know how they work

>callbacks
How are callbacks confusing? Functions are objects. You set callback field with functon. Things happen.
>>
>>51976180

It is my attempt at understanding closures that led to my post. I've never seen more confusing and unintuitive syntax for things in all my life.
>>
>>51976119
JavaScript was created in a week by one guy (probably without much sleep). And many of the flaws can't be fixed because of compatibility: no-one is going to use a browser which can't run a significant proportion of existing scripts, and no-one is going to write scripts which don't work in a significant proportion of browsers.

Having said that, many of the complaints from novices are about issues such as not doing blocking operations (e.g. waiting for data to load), so you have to use e.g. continuation-passing. But that's down to the operating environment, not the language.
>>
>>51976219
Okay, that one isn't a legitimate complaint. JS's closures are as straightforward as it gets.
>>
>>51974909
finger trees, because they make efficient catenable sequences possible in meme langs
>>
>>51976238
Not to mention if you just can't wrap your head around the lack of block scope for some reason, now you can use let which has block scope.
>>
/g/ humor: embedded edition

these are the comments on a "Hello world" 2 minute video showing how to change the text that says Hello World to "This is my first app"
>>
>>51976260
post link
>>
>>51974888
P Y T H O N
Y
T
H
O
N
>>
>>51976344
what're you working on my man
>>
>>51976344
explain why its good (its not)
>>
>>51976238

It's not closures I'm complaining about, fucker. It's just JS in general, shit like this:

Function.prototype.delay = function(ms /*[, arg...]*/) {
var fn = this,
args = Array.prototype.slice.call(arguments, 1);

return window.setTimeout(function() {
return fn.apply(fn, args);
}, ms);
};


is incomprehensible to me, what the fuck is "this," ?
>>
>>51976111
what is wrong with you
>>
>>51976364
Working on a simple script to scrape files off of gelbooru
>>51976368
You can get shit done quickly, and most of the time, performance is "good enough."
>>
someone told me to make an SSH client as a project

i think it might be 2 hard what do u guys think?
>>
>>51976368
I'm not him, but I picked up Python recently after a lot of C and I love Python. It's very fast to write and has loads of tools available that I didn't imagine would be so easy to use. (Some, not so much. I mean that I can download a file off the web in one short line, for example).
I don't like that the types are implicit, but having explicit and dynamic typing would be horribly confusing.
But, I do love it for how easy it is to write something in it, and especially for how easy and quick it was to learn it. I feel like it broadened my horizons and increased my potential in what I can make, but I lack any good ideas to take advantage of that benefit.
Regardless, I can write a quick program I just thought up for fun in an instant with Python, and while the performance is far less than I would expect with C, I feel like I can write my idea directly in Python and not have to worry about anything else. It's a good prototyping platform.

>>51976420
>scrape
Seems like that's all anyone [here] ever does with Python. Not that it's bad, just... what else can I do with it?

>>51976439
If you have to ask, yes it is too hard for you.
>>
>>51976449
there's no need to be a jerk about it

jerk
>>
>>51976403
absolutely nothing
>>
>>51976386
Let's start by making this code less visibly shit.

Function.prototype.delay = function(ms) {
var fn = this;
var args = Array.prototype.slice.call(arguments, 1);
return window.setTimeout(
function() {
fn.apply(fn, args);
},
ms
);
};


"this" is a reference to the object (of type Function) which has this method called. It's stored in "fn" because "this" inside the anonymous function would refer to something different.

It looks completely straightforward to me. That said, it's a pretty asinine way to go about doing what it's doing, leading to nonsensical calls like this: alert.delay(1000, "hi")

What don't you understand about it, besides "this?"
>>
>>51976458
lol, just trying to be clear
>>
>>51976386

`this` is the object that you're accessing `.delay` from.

function foo() { }
foo.delay(15)

In `delay` `this` is `foo`.
>>
>>51974888
There's a ton that can be done with Python, there's a huge amount of libraries available.
I just went with a gelbooru scraper because downloading porn is definitely something I'm going to be doing more than once, so why not automate it?
>>
>>51976482
but I'm a 3rd year CS student.

should I be non-retarded enough to accomplish this task?
>>
>>51976487
>>51976449
fug
I need to start using j/k to select posts before replying
>>
Python is the absolute worst language, and is literally only popular because of the dumb "It's a good starting language" meme. It teaches you terrible programming practises, its performance is terrible and is hardly even useful for anything.
>>
>>51976497
>hardly even useful for anything.
Ha ha ha
>>
>>51976497
>worst language
Your language has problems too, buddy.
There is no "best" language. Use the right tool for the job.
>>
Challenge: print the characters 'a' through 'z' in any programming language in 25 keystrokes or less. You may assume that compiling and running your program does not count towards your total number of keystrokes, only the number of characters in your source code. In languages with mandatory tabbing (i.e. Python, CoffeeScript), you can assume that tabs - which may be entered by your editor without you actually hitting a tab key - are free.
>>
>>51976497
>It teaches you terrible programming practises

Such as?
>>
>>51976497
>terrible programming practises

such as
>>
>>51976518
Not doing your homework for you kid
>>
Who Ada here?
>>
>>51976520
not him but python has a mantra "We're all consenting adults here", which is usually brought up when talking about encapsulation. Private variables basically don't exist in python, what it has is indicators that you shouldnt use something. (prepending an underscore means ayy this is private but you can use it anyway). If you add 2 underscores it mangles the name but you can still access it. If I wanted everything to be a struct with public access I'd use C.

And thats ignoring the fact that phrase is SJW as fuck. Muh rape culture.

Python is only popular with academics who don't know better and Hipster SJWs and people who would rather slap some feces together that runs 1000 times slower than a respectable language.
>>
>>51976569
>SJWs are why Python is bad
Please kill yourself
>>
>>51976488
Says nothing about your competence unfortunately. If you've done personal projects involving networking before, then you might give it a shot.

>>51976497
>literally only popular because of the dumb "It's a good starting language" meme.
Partially true, yeah. I think it's horrible for a first language, but people seem to equate "easy to write" with "good for beginners," which is just horrible.

>It teaches you terrible programming practices
If it's your first language, yeah.

>it's performance is terrible
It's interpreted lol

>hardly even useful for anything
This is where you're wrong. My guess is that since it's so crazily easy and fast to write in, people have made so many libraries for it, so it's usefulness is extreme. It also has some very convenient (not saying unique) language features.

>>51976518
Hi Ruby, gave this a shot:
putStrLn ['a'..'z']
>>
>>51976477

No, that was very helpful, thank you. I assumed the comma (got it from a stack overflow answer) was some bizarre syntax and not meant to be a semi-colon. Also I think the compounded methods and the fact that functions can be objects is what was frying my noob brain. Also what does the Function.prototype.delay even mean, why are we assigning a function to a method(?) and not a variable, and I thought you declared functions with "function " not whatever the hell that is
>>
>>51976582
I gave you a legitimate reason before I mentioned SJWs. One of many.
>>
>>51976309
https://www.youtube.com/watch?v=d6bW8xlx7TU

the humor is all of these people posing to pretend like this is some awesome resource, just so they can be seen.

Programming: much like the DJ/Producer of yesteryear, programming, aka "making apps" has become the latest must-have personality accessory.

there's also a few Pajeets in there too
>>
>>51976531

I'm on winter break. What homework?
>>
>>51976518
i couldn't go smaller than 50 characters...
int main(){char c='a';while(c!='{')putchar(c++);}
>>
>>51976599
"Thank you! Good job!"

as if he can now go and apply for the "Microsoft iOS Developer Programming Job" he was hoping for
>>
>>51976585
>Function.prototype.delay
This mean you add a method called "delay" to the preexisting class of objects called "Function" (aka, functions). The goal here is apparently so instead of doing this

setTimeout(function() { alert("dicks"); }, 500);


which is what normal and sane people do, you can do this

alert.delay(500, "dicks");


The array slice prototype shit carries forward all but the first argument (ms) into the apply() call, which is a method called on function objects which executes them (remember, fn was the old "this" which is the function object). Think argv.
>>
>>51976569
>runs 1000 times slower

the whole point of Python is that the speed is made up by its ease of use, who cares that something runs milliseconds faster when that time is easily cancelled out by the wasted seconds making your code conform to absurd syntax.
>>
>>51976631
>milliseconds faster
I'm in agreement with you but Python is far slower than that if you're doing anything big.
>>
Are paradigms a joke?

Everything seems to actually be procedural.
Sure, you can structure data into classes and throw in functions too, but the program it self is a list of instructions.
Same thing with FP. Your main function is just a list of function calls.
How is this any different, other than syntax?
>>
>>51976518
>>> map(chr, range(97, 123))
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
>>
>>51976584

19 chars, well done. Small as I can get in Ruby is 22.
p ('a'..'z').to_a.join


>>51976607

You also forgot to forward declare putchar. The compiler will bitch at you for that. Still, not bad for minimalism, though this challenge obviously seems to only work well for terse languages. I'm waiting for the perl and python programmers.
>>
>>51976668
lol if you think about it that way i guess yeah, paradigms are just really big memes
>>
>>51976668
[spoiler]The syntax IS the paradigm[/spoiler]
>>
>>51976672
>The compiler will bitch at you for that.
not really, unless you have -Wall turned on like some kind of autist
>>
>>51976670
>>> map(chr, range(97, 123))
<map object at 0x0000000003515EF0>


I don't see any way around a for ... in iteration.
>>
>>51976518
easymode
using System.IO;
using System.Linq;

class HelloWorld : Object
{
public static readonly letters = "abcdefghijklmnopqrstuvwxyz"

public static int main(string[] args)
{
IEnumerable<char> characters = Enumerable.Range(0,25).Select(x => letters[x]);

foreach(char chr in characters)
{
Console.Write(chr);
}
return 0;
}
}
>>
>>51976706
works on the only version of python that matters, 2
>>
>>51976719
25 keystrokes
25 characters anon
not 25 lines
>>
>>51976720
>using python 2.shit
Literal caveman, how are you enjoying your print keyword?
>>
>>51976706
list(map(chr, range(97, 123)))
>>
>>51976672
14 in perl
print 'a'..'z'

>>51976745
25 characters
>>
>>51976518

for i in range(1,26):
print (chr(ord('A')+i))
>>
import string
[ch for ch in string.ascii_lowercase]
>>
>>51976719

this is making me laugh so hard
>>
>>51976672
Funny enough, I actually tried it in Python first, turns out the whole "text is an abstraction" idea got in the way.

>>51976670
You're not *really* printing them though, that's just the REPL printing the return value. Good hack though.

>>51976745
Not quite printing still, though. even print(<that>) gives the same.

Here's the best I could do, /actually/ printing it in Python:

print(''.join(map(chr, range(97, 123))))


I'm probably missing something obvious, rather new to Python.
>>
>>51976765
>>51976758
25 keystrokes you pieces of shit
read
>>
>>51976719
kek
>>
>>51976765
>[ch for ch in
what's the point in it
>>
>>51976773
You might as well just print(list(map(...))) then. Fewer characters.
>>
>>51976778
//python
[x for x in xs]
//haskell
[x | x <- xs]

If that helps you understand. You couldn't do
[x <- xs]

now, could you?

>>51976785
While it technically /does/ print the letters 'a' through 'z', it prints them out in that list notation (['a', 'b', ... 'z']), and I felt that wouldn't fit the bill.
>>
>>51976778
there wasn't one
>>> import string
>>> print([ch for ch in string.ascii_lowercase])
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
>>> print(string.ascii_lowercase)
'abcdefghijklmnopqrstuvwxyz'
>>>

still above 25 keystrokes though :^)
>>
>>51976773
>Here's the best I could do
Alternatively you can do:
print(*map(chr, range(97, 123)), sep='')
>>
>>51976806
Seems to be a Python 3 feature I haven't seen before, neat.
>>
>>51976731
Here. Under 25 lines
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

namespace Hello
{
public static class HelloWorld : Object
{
public static readonly letters = "abcdefghijklmnopqrstuvwxyz"
public static System.Collections.Generic.IEnumerable<char> getCharacters()
{
foreach(int i in Enumerable.Range(0,letters.Length))
{
yield return letters[x];
}
}
public static int main(string[] args)
{
foreach(char chr in getCharacters())
Console.Write(chr);
return 0;
}
}
}
>>
>>51976607
i got it down to 45 chars
main(){char c='a';while(c<'{')putchar(c++);}
>>
>>51976804
Instead of
[ch for ch in string.ascii_lowercase]
You could just write
list(string.ascii_lowercase)

I don't see why you use list comprehension if you don't modify elements and there is no if.
>>
>>51976821
use 97 for 'a', it's 1 less character.
>>
>>51976806
What in ze fuck

Is there a name for that syntax?
>>
>>51976831
Also, '{' is 123. You can save another character
>>
>>51976518
I don't think it can get shorter than this in js unless I'm missing something:
for(i=97;i<123;)console.log(String.fromCharCode(i++))


php can tho:
<?for(;$i<26;)echo chr(97+$i++);
>>
>>51976849
'{' = 3 chars
123 = 3 chars

>>51976847
Splat operator. Flattens the list.
>>
>>51976831
kay
main(){char c=97;while(c<123)putchar(c++);}
>>
>>51976866
Just use the hex code 7B
You save 1 character.
>>
>>51976875
You'd have to do 0x7B unfortunately.
>>
H-hey guys, can C# play too?

Microsoft (R) Roslyn C# Compiler version 1.1.0.51204
Loading context from 'CSharpInteractive.rsp'.
Type "#help" for more information.
> for(char c='a';c<'{';c++){Console.Write(c);}
abcdefghijklmnopqrstuvwxyz


44 characters. Tied with C?
>>
>>51976900
C is at 43 characters, close though. You should look at the C solution, too. You can trim that down a lot.
>>
>>51976870
42 characters!
main(){int c=97;while(c<123)putchar(c++);}
>>
>>51976851
PHP 32 chars.

Languages the challenge is possible in:
Ruby (22), Perl (14), Haskell (19)

Languages that come... close:
Python, C, PHP, Javascript

Can anyone do it in a lisp?
>>
perl6
>>
>>51975609
Do you mean like string.translate?

or into binary, increment a bit, into character?
>>
>>51976913
char c='a';while(c<'{')Console.Write(c++);


42 characters, tied. Also,
>tfw "cannot implicit convert 'int' to 'char'" prevents you from getting 41
>>
>>51976753
this is awesome
>>
>>51976917
python is 28
>>
>>51976518
Ok, here is my solution in C:
a(b){a(putchar(b)+1);}

Compile with
gcc -std=c89 -c program.c
objcopy --redefine-sym a=main program.o
gcc program.o program

Then invoke with
./program {1..96} | head -c 26
>>
>>51976914
alright i literally cannot go any shorter without getting compiler errors
using a variable declaration inside a for loop means I have to go C99 and C99 has issues with implict calls to putchar and not giving main a return type.
>>
>>51976518

bash:

echo {a..z}
>>
>>51977013
You're using C and bash there, anon.
>>
>>51977023
*
echo {a..z}|tr -d ' '
>>
>>51977029
The {1..96} is just so I don't have to type 96 arguments by hand. You can do that if you want.
The redirection to head is just so you can see the relevant characters. It definitely prints a-z and the requirements didn't say we weren't allowed to print anything else, so you can remove that pipe if you want.
>>
>>51977045
reqs said nothing about spaces :P
>>
>>51977013
heck - why have any source code at all?
$ ./myprogram | echo "abcdefghijklmnopqrstuvwxyz"
>>
i=97;while(i<123)console.log(String.fromCharCode(i++))


54 characters in JS. It would be like 30 if you didn't have to qualify console.log and String.fromCharCode wasn't so goddamn long.
>>
>>51977013
Exploitation of the rules. I like it! Although nonetheless, very cheap.

>>51977023
11 chars. Goddamn. Well done, Bash.
>>
>>51977070
i=97;while(i<123)[print(String.fromCharCode(i++))


I think this works (48 chars), but the console display things weird and it ends up just showing "z".
>>
someone put the alphabet in a .txt. file and then open/print it in under 25
>>
>>51977070

Same amount of chars in CoffeeScript
console.log(String.fromCharCode(c)) for c in [97..123]
>>
>>51977096
That opening bracket is a typo.
>>
>>51977101
echo "abcdefghijklmnopqrstuvwxyz

or better yet...
echo {a..z}|tr -d ' '
>>
julia:
for i=97:122;print(char(i));end
>>
>>51976945
that is actually exactly what I'm looking for
thanks
>>
I don't think it can get much smaller in go:
package main;func main(){for c:='a';c<'{';c++{print(string(c))}}
>>
cout<<"abcdefghijklmnopqrstuvwxyz"<<endl;


CHECKMATE FAGGOTS
>>
>>51977198
>Over 25 characters
>Didn't include any of the boilerplate
>Implying that is a complete program
>>
>>51977223
it's pretty shitty alright, how would you even do this in c++
>>
>>51977234
I managed to do it in C under 25 characters.
I'm sure you can do it in C++; people keep telling me it's a more expressive and higher level language while being a superset of C
:^)
>>
>>51977252
you cheated
the shortest self-contained C program is >>51976914
>>
>>51977127
Neat.
>>51977193
Can't do print(string(c++))?
>>
>>51977252
MAH OOP
>>
>>51977284
>you cheated
How? Sure, my program does have some undefined behaviour and only stops executing when it crashes, how it it a violation of the rules? The bash stuff was just for convenience, and is not required for correct execution of the program.
>>
>>51977308
nope, ++ doesn't return a value in go or something
>>
>>51977379
holy moly
>>
>writing a simple C program after having not used C for over a month
what am I doing
I should practice every day so I don't get rusty again holy shit
>>
>>51977415
you havent been programming for very long
once you reach a certain point, your skills no longer evaporate after not looking at code for a week
>>
>>51977448
It's been nearly 2 years that I've been using C. Maybe it's becuase over the past month I have been using other languages, which is a first for me. Or maybe 2 years isn't that long, lol
>>
File: oc.png (5 KB, 150x150) Image search: [Google]
oc.png
5 KB, 150x150
>>51974888
rate my meme picture
>>
File: calculator.jpg (480 KB, 2880x1800) Image search: [Google]
calculator.jpg
480 KB, 2880x1800
r8 my Swift calculator, now it rotates! Soon will add support for the split view thingy (really boring though, I have to design a 1/3 portrait view, 1/3 landscape and 2/3 landscape views)

It will be open source and free on the app store when I'm done with it.
>>
there's a point where this needs to stop and I've clearly passed it:
for(i=0,a=[];i<26;a[i++]=i+96);console.log(eval("String.fromCharCode("+a.join(",")+")"))


good night
>>
File: 1243961841738.jpg (37 KB, 624x352) Image search: [Google]
1243961841738.jpg
37 KB, 624x352
>>51977509
Post code.


char Cipher(char c, unsigned short int shift)

{

if(c > 64 && c < 91) /* >= 'A' && <= 'Z' */

{

c += shift;

if(c > 90) /* > 'Z' */

{

c -= 26;

}

}

else if(c > 96 && c < 123) /* >= 'a' && <= 'z' */

{

c += shift;

if(c > 122) /* > 'Z' */

{

c -= 26;

}

}

return c;

}
>>
>>51977550
main = (return ()) >> (return ()) >> (return ())
>>
>>51977284
Oh wow gtfo
>>
File: vacuumagent.webm (101 KB, 34x52) Image search: [Google]
vacuumagent.webm
101 KB, 34x52
Rate my Vacuum implementation, /dpt/

>>51977542
Nice work anon!

>>51977547
Sleep well friend

>>51977550
Too much whitespace.
>>
File: .png (186 KB, 1366x768) Image search: [Google]
.png
186 KB, 1366x768
HOW
>>
>>51977666
go away satan
>>
>>51974888
include "stdio.h"
include "windows.h"
void main()
{
cout <<< "c++ is stoopid!";
return 0;
}


lerning c++ for scool, it's weird and i hate it.
>>
>>51977709
You're stupid and retarded.
Thread replies: 255
Thread images: 27

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.