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

/dpt/ - Daily Perentie Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 338
Thread images: 21

File: 21-Perentie-Goanna.jpg (686KB, 1200x900px) Image search: [iqdb] [SauceNao] [Google]
21-Perentie-Goanna.jpg
686KB, 1200x900px
What are you working on, /g/?

Previous thread: >>61162895
>>
First for C#
>>
>>61172158
Second for C++
>>
nth for why arent you working on that project, /dpt/?
>>
Interfacing SDL2 for OCaml.
>>
>>61172184
>OCaml
Such a practical language, the official implementation can't even do multicore yet
>>
>>61172203
>the official implementation can't even do multicore yet
absolutely embarrassing
>>
>>61172203
And? I see no problems here. It will come, or not. But it's useless. Look at what JaneStreet does.
>>
>>61172177

I'm a lazy piece of shit.
>>
File: old_hag_langs.png (173KB, 600x355px) Image search: [iqdb] [SauceNao] [Google]
old_hag_langs.png
173KB, 600x355px
>>61172158
>>61172174
This is fine.
>>
"multicore is useless"
-/dpt/
off to a good start.
>>
Post a better string reversal in C.
void reversal(char* r){
size_t len = strLen(r);
char* f = r+len-1;
for(;r<=f;r++,f--){
*r += *f;
*f = *r - *f;
*r -= *f;
}
}
>>
>>61172237
>we are incompetent and cannot make compiler that support native threads
>BRO just spawn another process, like dude who needs threads when operating system can manage proceses LOL.
yeah fuck ocaml
>>
>>61172237
>it's useless
Incredible, we found a language more useless than Haskell!
>>
>>61172272
>>61172278
>>61172296
How to troll /dpt/ in a nutshell.
>>
>>61172272
Not having multicore works for Python, and as we all know Python is the best language because it just works
>>
File: 1498434929445.png (251KB, 555x720px) Image search: [iqdb] [SauceNao] [Google]
1498434929445.png
251KB, 555x720px
>>61172149
C influenced languages get an automatic F in my book.
>>
D was robbed. D is far more useful than OCaml will ever be, and yet it is dead.
>>
>strings in his favorite language aren't mutable
>>
>>61172331
D is shit

whoops

D was shit
>>
File: retard.png (331KB, 600x1081px) Image search: [iqdb] [SauceNao] [Google]
retard.png
331KB, 600x1081px
>>61172306
>>
>>61172331
Who the fuck thinks Ocaml is relevant?
Its even lower on github stats than D.
>>
#!/bin/sh

set -e

i=1
while [ $i -le 100 ]
do
if [ $((i % 15)) -eq 0 ]
then
echo "fizzbuzz"
elif [ $((i % 5)) -eq 0 ]
then
echo "buzz"
elif [ $((i % 3)) -eq 0 ]
then
echo "fizz"
else
echo "$i"
fi
i=$((i + 1))
done
>>
>>61172368
>Who the fuck thinks Ocaml is relevant?
OCaml is the future. People start slowly to realize it.
>>
I am working on documentation for a project. Why is texinfo so comfy?
>>
>>61172331
>D
>useful
>>
When will the K&R bracket indentation meme die, /dpt/?
>>
I hate my coworkers who are autistic about CRUD forms not being properly aligned, not having the right number formatting, input labels not having colons, etc. They take bikeshedding to the extreme.
>>
>>61172368
The anon making an SDL2 interface for it evidently does.
>>
>>61172390
>OCaml is the future.
Not with that god awful syntax its not.
Its not even a good functional language.
And even D is a better functional.
>>
>>61172390
OCaml is impure trash
>>
>>61172390
The future is multicore.

OCaml does not support multicore.
>>
>>61172427
It will, just be patient. And right now, what are you doing that need multicore and can not be done with multiprocesses?
>>
Idris > Haskell > Scala > OCaml
>>
>>61172177
too lazy, and I'm already taking decisions about its design. that makes me anxious...

>>61172267
hey, how are you doing, you libertarian-statist-religious-transexual-racemixer?
>>
2.9G    ./gcc
2.8G ./linux


w-what... gcc repo bigger than linux repo?

>>61172177
i am working on it

>>61172467
this is a fact
>>
>>61172451
>It will
It won't in our lifetime.
>>
which should i learn: common lisp or haskell?
>>
>>61172451
>It will, just be patient.
Or, just use a language that has had solid multicore support for years, i.e. almost any other language in use today.
>>
>>61172395
Hopefully right now.
>>
>>61172487
Facts: The odd of using OCaml increase with developer skills.
The odd of using C++ decrease with developer skills.

It's just a matter of time.
>>
>>61172498
scheme and idris
>>
>>61172149
learn Go
https://tour.golang.org
https://www.golang-book.com
>>
>>61172526
i-i want to write real software though...
>>
>>61172467
>Idris > Haskell >= Scala = OCaml
ftfy
>>
>>61172516
Facts: after a certain point, the odds of learning ocaml decrease with developer skill and the odds of using idris increase with developer skill
>>
>>61172498
haskell then idris
>>
>>61172516
tfw to intelligent to use a language that supports multicore
>>
>>61172516
Facts: You are homo. Ocaml doesn't currently support native threads. Even if it got it implemented now it would still takes years to mature.
>>
>>61172421
What is an ``functional language" though?
>>61172543
What is an ``real software"?
>>
>>61172516
literally what is good about ocaml
>>
File: go_is_trash.png (9KB, 230x173px) Image search: [iqdb] [SauceNao] [Google]
go_is_trash.png
9KB, 230x173px
>>61172544
Haskell is strictly superior to Scala
Scala is strictly superior to OCaml

>>61172542
Haskell is strictly superior to Go
>>
>>61172546
He might as well just skip Shitkell altogether.
>>
>>61172561
Purity + fast production with HOF.
>>
>>61172564
>literally what is good about ocaml
No stupid shadow warning.
No implicit recursion.
Type inference.
Pattern safety.
Fast.
>>
>>61172561
>What is an ``functional language" though?
A language that is not a dysfunctional language

Dysfunctional languages include Python, Go, and JS
>>
>>61172569
>Haskell is strictly superior to Scala
I don't know about that, anon. They seem very much the same to me.
>Scala is strictly superior to OCaml
Scala and OCaml can be shown to be the same language.
>>
>>61172577
that's dumb advice
>>
>>61172368
More wealth is created using OCaml than several languages with more "open source" présence. Including D.
>>
>>61172375
Should I learn perl or shell script?
I know shell script use glibc runtime.
What does perl use?Also my company, NVIDIA wants me to learn perl.
But for my personal use which would be better?
>>
>>61172583
>Purity
Purity as in "Purity" or Purity as in ``````purity"""?
>fast production
In what units do you measure these ``productions"?
>>
>>61172277
void reversal(char *r){
size_t len = strlen(r);
for(char *f = r + len - 1; r < f; r++, f--){
*r += *f;
*f = *r - *f;
*r -= *f;
}
}
>>
File: 1493967545771.jpg (26KB, 311x296px) Image search: [iqdb] [SauceNao] [Google]
1493967545771.jpg
26KB, 311x296px
>>61172610
That's for the best, though.
>>
>>61172277
It's cute but it's not especially readable.
>>
>>61172625
Shell. Useful all around, but knowing a bit of perl (especially the regex) can help quite a lot. Especially the one-liners.
>>
>>61172625
>Should I learn perl or shell script?
Is it a true question?
>>
File: scala-wat.png (28KB, 524x87px) Image search: [iqdb] [SauceNao] [Google]
scala-wat.png
28KB, 524x87px
>>61172609
>They seem very much the same to me.
Pic related doesn't happen in Haskell. Also Haskell has much better type inference and stack safety.

>Scala and OCaml can be shown to be the same language.
Scala supports multicore. OCaml does not.
>>
Should really change the title to /dlf/ - Daily Language Fight.
>>
>>61172627
But the question is, are you a ```````````````````````````````````````````````programmer'''''''''''''''''''''''''''''''''''''''''''''''?
>>
>>61172598
>dysfunctional language
What is an ``dysfunctional language"?
>Dysfunctional languages include Python, Go, and JS
I need a full list or an algorithm for generating that list.
>>
>>61172639
hmm u just made C++11 relevant
>>
>>61172619
>présence

INRIA shill pls go
>>
>>61172619
die kike
>>
>>61172653
Yes, asking it.
>>
>>61172675
I actually worked for Inria at some point. We used sepples though.
>>
>>61172639
void reversal(char *r){
for (char *f = r + strlen(r) - 1; r < f; r++, f--)
{ *r += *f; *f = *r - *f; *r -= *f; }
}
>>
>>61172656
competition breeds progress.
>>
>>61172682
Learn shell, and avoit spending time on perl. There are a ton of more useful things to learn, like OCaml or Coq or Haskell or...
>>
>>61172694
>inria itself doesn't even use its garbage language
>>
>>61172718
You're so wrong.
>>
>>61172639
kek
>>
>>61172569
>comparing only based on a single performance metric
by that logic, C >> *
also,
http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=go&lang2=ghc
>>
Rate my code, /dpt/

int64_t fibonacci(uint8_t n)
{
if (n <= 1) return n;
/* if n is greater than 92, fail */
if (n > 92) return -1;
n -= 2;

uint64_t a = 1, b = 1, c = 0, d = 1, e = 1, f = 0;

while (n) {
uint64_t g, h;
if (n & 1) {
g = a * d + b * e;
h = b * d + c * e;
f = b * e + c * f;
d = g;
e = h;
}
g = a * b + b * c;
a = a * a + b * b;
c = b * b + c * c;
b = g;
n >>= 1;
}

return d;
}
>>
>>61172739
>linking to the rigged benchmarks
>>
File: smug_ran.jpg (632KB, 709x1063px) Image search: [iqdb] [SauceNao] [Google]
smug_ran.jpg
632KB, 709x1063px
>>61172739
>C >> *
Is this even wrong though?
>>
>>61172718
It wasn't really the appropriate domain (medical simulation).
>>
>>61172751
stop avatarfagging this instant
>>
>>61172277
>no xor swap
>>
>>61172739
>
pidigits
source secs mem gz cpu cpu load
Go
0.13 ? 603 0.13 0% 0% 0% 100%
Haskell GHC Make Error


>the state of hasklet
>>
File: chen.png (106KB, 382x526px) Image search: [iqdb] [SauceNao] [Google]
chen.png
106KB, 382x526px
>>61172762
That was a reaction image.
>>
>>61172758
Fair enough, for that stuff you want code that you can prove correct
>>
>>61172785
i know your game
>>
>>61172747
Nice O(logN) complexity you got there :)
>>
>>61172751
Yes, C++ is faster when you're sorting.
>>
>>61172777
xor swap isn't really efficient (most compilers detect an auxiliary variable swap and just replace it with XCHG instruction).
also, it can fail if you xor the same value (same address), and that could be the case here because
 r<=f 
>>
>>61172851
just make one sort function per type
>>
There are 100 bulbs and switches in a room.
There are 100 fags.
1st fag toggles all the switches.
2nd fag toggle multiple of 2 numbered switches.
.
.
rth fag toggle multiple of r numbered switches.
100th fag toggle only 100th switch.
At the end of this experiment. How many bulbs are switched on?Assume your own initial state of bulbs.
>>
>>61172924
idgaf
>>
>>61172924
>faggot doesn't provide the initial state of the lights
>>
let print oc = function
| [] -> Printf.fprintf oc "0"
| l ->
let l = List.rev l in
List.iter (Printf.fprintf oc "%d") l
;;

let add l1 l2 =
let add_digit a b c =
let n = a + b + c in
n / 10, n mod 10 in
let rec loop accu carry l1 l2 =
match l1, l2 with
| [], [] ->
if carry > 0 then
carry :: accu
else
accu
| l1, [] -> loop accu carry l1 [ 0; ]
| [], l2 -> loop accu carry [ 0; ] l2
| x1 :: l1, x2 :: l2 ->
let carry, n = add_digit x1 x2 carry in
loop (n :: accu) carry l1 l2 in
List.rev (loop [] 0 l1 l2)
;;

let rec fib a b = function
| 0 -> ()
| k ->
Printf.printf "%a" print a;
print_newline ();
fib b (add a b) (pred k)
;;

let () = fib [] [ 1; ] 100;;
>>
>>61172929
>>61172960
weaklings
>>
>>61172807
lol literally no one in the scientific computing field cares about program correctness. The most involved thing you'll see is manufactured solution checks.
>>
/dpt/ should resurrect /prog/
>>
>this is illegal in lisp
(with-open-file (urandom "/dev/urandom" :diretion :input)
(read-byte urandom))
>>
>>61173014
My question was fucking relevant. Assuming they start OFF,

Total[[email protected]@[email protected][#] & /@ Range[100]]

10 lights will be on
>>
>>61173072
why?
>>
File: 1489980970724.png (245KB, 1000x935px) Image search: [iqdb] [SauceNao] [Google]
1489980970724.png
245KB, 1000x935px
>>61172980
Beautiful.
>>
>>61173087
I know.
>>
>>61173070
Imagine /prog/ with today's /dpt/ subjects
>What's the best language which doesn't use I/O?
>who are you quoting?
>what's a "functional programming"?????
>Seriously, piss off to >>>/r/abbit
>Can /prog/ sum all prime numbers under 2 millions?

No thanks.
>>
without realizing it, i had to implement a generalization of fizzbuzz for an actual hobby project

>>61173103
HAX MY ANUS
>>
>>61173072
>:diretion
>>
>>61173085
>>
File: 1493947666731.jpg (214KB, 1454x1454px) Image search: [iqdb] [SauceNao] [Google]
1493947666731.jpg
214KB, 1454x1454px
>>61173118
>a generalization of fizzbuzz
Share it.
>>
>>61173082
wrong.
>>
>>61173138
Still doesn't work.
>>
>>61173146
should have specified the element type, dumb cunt.
>>
File: 1495296329197.png (29KB, 223x446px) Image search: [iqdb] [SauceNao] [Google]
1495296329197.png
29KB, 223x446px
Has anyone here studied the properties fizzbuzz?
>>
>>61173166
lmao
>*** - open: Illegal :element-type argument integer
>>
File: goanna.jpg (874KB, 860x1152px) Image search: [iqdb] [SauceNao] [Google]
goanna.jpg
874KB, 860x1152px
Have you hugged your perentie today?
>>
>read K&R over a year ago
>get comfortable with the basics of C, my first programming language
>haven't touched it in a year but want to get back into it since I've built a new PC

What do I do once I finish K&R as a C hobbyist? Just learn a new language?
>>
>>61173189
I despise reptiles.
>>
>>61173173
Some autist here was adding more and more stuff to his Idris proof
>>
>>61173194
Nope, you go a 100% and learn useful shit
>>
>>61173194
That's a nice story, but who are you quoting?
>>
>>61173194
learn the POSIX standard and start developing programs in C for UNIX-like OS.
>>
>>61173194
Write a driver for your GPU for TempleOS.
>>
>>61173194
buy transitors, buy bread board. make a circuit. write device driver.
>>
Tfw no pet programmer trap to chain to a laptop.
>>
>>61172177
I can't stop playing CS.
>>
>>61172277
void reverse(char *r) {
/* Inlining strlen to avoid function call overhead.
Credit to the FSF for the strlen implementation being inlined
and to http://www.stdlib.net/~colmmacc/strlen.c.html for the
reference text.
This is not exactly strlen; it doesn't return the length, and
it's been modified to stop at the last character, instead of at
the null terminator.
DISCLAIMER: I haven't tested this. I changed a lot of the
strlen in the process of inlining it to this specific use case,
so it's possible it might not even work anymore. */
char *f;
for (f = r; ((long) f) & (sizeof(long) - 1); f++) if (!*f) break;
if (*f) {
unsigned long himagic = 0x80808080L, lomagic = 0x01010101L;
if (sizeof(long) > 8) abort();
else if (sizeof(long) > 4) {
himagic = ((himagic << 16) << 16) | himagic;
lomagic = ((lomagic << 16) << 16) | lomagic;
}
for (;;) if (((*(long*) f) - lm) & hm) {
for (int i = 0; i < sizeof(long) - 1; f++)
if (!f[1]) goto double_break;
} else f += sizeof(long);
} double_break:
// End of inlined strlen. Actual reverse function:
for (; r < f; r++, f--) { // changed <= to <
*r += *f;
*f = *r - *f;
*r -= *f;
}
}
>>
>>61173155
Cancer like you is what's destroying the thread
>>
>>61173138
what lisp is that? and which implementation?
>>
>>61173256
NOT PORTABLE
>>
>>61173256
Slight adjustment. (See quoted post for documentation.)
void reverse(char *r) {
char *f;
for (f = r; ((long) f) & (sizeof(long) - 1); f++) if (!*f) {
f--; goto double_break;
}
unsigned long himagic = 0x80808080L, lomagic = 0x01010101L;
if (sizeof(long) > 8) abort();
else if (sizeof(long) > 4) {
himagic = ((himagic << 16) << 16) | himagic;
lomagic = ((lomagic << 16) << 16) | lomagic;
}
for (;;) if (((*(long*) f) - lm) & hm) {
for (int i = 0; i < sizeof(long) - 1; f++)
if (!f[1]) goto double_break;
} else f += sizeof(long); double_break:
for (; r < f; r++, f--) {
*r += *f;
*f = *r - *f;
*r -= *f;
}
}
>>
>>61173299
Not portable? To what exactly?
To 16-bit computers? Because no one cares anymore.
To 128-bit computers? Because no one cares yet.
>>
>>61173348
>works on my current machine :^)
>>
Imagine using a language that doesn't support multicore
>>
>>61173364
Imagine using a language that doesn't support nightcore
>>
>>61173364
Which one of the two ocaml or python?
>>
>>61173326
why is this efficient than original poster's reversal?
>>
>>61173364
Can't believe people use C in this day and age
>>
>>61173358
Muh portability
>>
>>61173398
#include <conio.h>
>>
I have two questions:

One... what's a good laptop for professional development, likely doing a lot of c#. I'm thinking of getting an XPS with 16g memory, but I'm not sure how their battery life is. Gotta choose a computer for the company to buy me.

Second question, who wants to dress up in cute girly clothes and kiss my feet?
>>
>>61173382
uguu
>>
>>61173404
>who wants to dress up in cute girly clothes and kiss my feet
You should dress up and kiss your own feet
>>
>>61173412
What about the laptop though!?!
>>
>>61173386
1) It avoids the overhead of actually calling strlen by just sticking it in there.
2) It avoids the overhead of subtracting 1 from the result of strlen by having """strlen""" stop at the correct character.
3) It avoids the overhead of having to advance the pointer twice (once inside strlen and once after it) by using the same pointer inside """strlen""" that we want to advance.
>>
>>61173404
>Second question, who wants to dress up in cute girly clothes and kiss my feet?
Do you have a big hard cock?
>>
>>61172375
#!/bin/bash

for n in {1..100}; do
fb=
(( n % 3 )) || fb=fizz
(( n % 5 )) || fb=${fb}buzz
echo ${fb:-$n}
done
>>
>>61173404
Get a professional hp.
>>
>>61173404
I'm working on a XPS 9560. The only problem I have is the blown up speakers.
What about you dressing up as a girl and kissing my feet instead?
>>
>>61173404
It has really good battery life.
Also,
>>61173299
Wants to dress up in cute girly clothes an kiss your feet, but only if you're feet are portable.
>>
>>61173149

in pseudocode, simplifying a bit:

triggers = reverse([(10, fun_10), (20, fun_20), (50, fun_50), (100, fun_100)])
count = get_count()
for k, v in triggers:
if count == k:
v()
break


if it was fizzbuzz, the array would have 15, 5, 3 as the first three items. if I also cared about printing the number when it's not a fizzbuzz, i'd have included a -1, default function that took count as an argument.
>>
>>61173212
>2011+6
>(You)
>>
>>61173388
Multicore is _implemented_ in C.
>>
>>61173431
Not at the moment, but sometimes.

>>61173445
>What about you dressing up as a girl and kissing my feet instead?
Nah, I only sub for girls.

>>61173436
I'll look into them. Haven't really used an HP in like over a decade.

>>61173446
>It has really good battery life.
Appreciated.
>>
>>61173194
here's a non shitpost answer. find something you like (network? chat? image/video streaming/processing? audio streaming/processing? evolutionary algorithms? lossless compression? lossy compression? games?), then search for libraries to help you, then develop an app for that domain.

Just do projects with it and have fun.
>>
>>61173072
>>
>>61173072
Worked for me. Hyperspec doesn't say anything about unbuffered filestreams. What lisp are you using?
>>
>>61173326
I fixed your shitty code, there was a logic error and also it wasn't pythonic.
void reverse(char *r) {
char *f = r;
if (!*f) return;
for (; ((long) f) & (sizeof(long) - 1); f++) if (!f[1]) {
f--; goto reversing; }
unsigned long himagic = 0x80808080L, lomagic = 0x01010101L;
if (sizeof(long) > 8) abort();
else if (sizeof(long) > 4) {
himagic = ((himagic << 16) << 16) | himagic;
lomagic = ((lomagic << 16) << 16) | lomagic; }
for (;;) if (((*(long*) f) - lm) & hm) {
for (int i = 0; i < sizeof(long) - 1; f++)
if (!f[1]) goto reversing; }
else f += sizeof(long);
reversing: for (; r < f; r++, f--) {
*r += *f;
*f = *r - *f;
*r -= *f; } }
>>
>>61173426
So you pasted the glibc strlen in the function?
I want to know about himagic and lowmagic, where do I start?
>>
>>61173504
u fucked up some of curly braces. Like the 2nd for loop
>>
>>61173507
Pasted? No, not exactly. I omitted a few things that were unused, etc.
>I want to know about himagic and lowmagic, where do I start?
This would be a good place to start: http://www.stdlib.net/~colmmacc/strlen.c.html
They're just bitmasks for checking if it's likely there's a 0 byte in a word
>>
>>61173516
believe it or not that's the way it is on purpose
>>
>>61173488
>read-char
dolly a470
I need read-byte because some sequences aren't legal chars, faggots.
>>
>>61173445
>>61173446
>>61173436
Probably going with the 9560 high-end model.

Now to just figure out how to get a pet.
>>
>>61173488
thats a sexy font
>>
>>61173551
I believe in you anon, I haven't run it but I think your pythonic C is dank

>avoiding binding to outer else using one curly
>>
>>61173488
>racket
>>61173500
sbcl
>>
>>61172544
>Idris > OCaml > Haskell > Scala
ftfy
>>
>>61173579
er, binding with the inner if statement, I mean
>>
>>61173585
Try following the thread, doggo. We've debunked the idea that OCaml is in any way useful.
>>
>>61173348
>To 16-bit computers? Because no one cares anymore.
but anon what if i want to reverse a string on a sega genesis
>>
>>61173566
>dolly a470
what?

>>61173566
>I need read-byte
i did use read-byte too (first three calls).
>>
>>61172544
>Scala = OCaml
but camels don't have scales
>>
>>61173580
you said in lisp with specifying which lisp.
>>
>>61173580
In SBCL, I get
#<SB-SYS:FD-STREAM for "file /dev/urandom" {1002529473}> is not a binary input stream.

It worked in ECL though. Strange.
>>
>>61173619
sorry that was the captcha
I need it in Common Lisp
>>
>>61173540
Do you know of a way to precisely measure the performance of '\0' terminated custom strlen and inlined strlen that you wrote?
I am thinking having a long word and use clock_t start and begin for measuring time?
>>
>>61173633
To add, Hyperspec says this about binary streams:
binary adj. 1. (of a stream) being a stream that has an element type that is a subtype of type integer. The most fundamental operation on a binary input stream is read-byte and on a binary output stream is write-byte. See character. 2. (of a file) having been created by opening a binary stream. (It is implementation-dependent whether this is an detectable aspect of the file, or whether any given character file can be treated as a binary file.) 
>>
>>61173633
can urandom opened in binary mode? have you checked the linux manual?
>>
>>61173504
>pythonic
So, fucked curly braces?
>>
I'm going through a book and learning Racket.

[spoiler]And I like it. Is this path to enlightment?[/spoiler]

[spoiler]I dabble with C# at work[/spoiler]
>>
>>61173699
>racket lists are immutable
>>
>>61173699
Learning a Lisp is great even if you don't end up liking it.
>>
>>61173504
Okay last fix this time I swear to god.
void reverse(char *r) {
char *f = r;
if (!*f) return;
for (; ((long) f) & (sizeof(long) - 1); f++) if (!f[1]) {
f--; goto reversing; }
unsigned long himagic = 0x80808080L, lomagic = 0x01010101L;
if (sizeof(long) > 8) abort();
else if (sizeof(long) > 4) {
himagic = ((himagic << 16) << 16) | himagic;
lomagic = ((lomagic << 16) << 16) | lomagic; }
for (;;) if (((*(long *) f) - lomagic) & himagic) {
for (int i = 0; i < sizeof(long) - 1; f++)
if (!f[1]) goto reversing; }
else f += sizeof(long);
reversing: for (; r < f; r++, f--) {
*r += *f;
*f = *r - *f;
*r -= *f; } }
>>
>>61173724
which is great, actually. racket also has mutable list if you need but it's not the default list type.
>>
>>61173326
>for else
This isn't python is it? It works in C? Or am I reading wrong?
>((himagic) << 16) << 16)
Why not just << 32 once?
>>
>>61173725
So I've heard. But I dont ever think to have seen a job listing where they are looking for people who know lisp. Is it dead?
>>
>>61173755
>he has to copy the entire list for any operation
>>
>>61173645
That sounds reliable. You could also do it out-of-program with the time command but idk how reliable that is
>>
>>61173763
>This isn't python is it? It works in C? Or am I reading wrong?
The else belongs to the if that comes right after the for (;;)
>Why not just << 32 once?
Beats me, the implementation I was adapting from did << 16 twice and I figured there must be a reason
>>
Why is lisp and the alike so comfy? C also.

Java/c# feels like a bloat whore on a tuesday night.
>>
>>61173824
Lisp is bloat central though
>>
>>61173824
>Why is lisp and the alike so comfy? C also.
>Java/c# feels like a bloat whore on a tuesday night.
These languages are not pythonic :^(
>>
>>61173839
because of (((((()))))))))))))?
>>
>>61173853
Not him but lisp really is quite bloated and it has nothing to do with all the parentheses
>closures
>classes
>recursion
>>
>>61173853
Lisp binaries are 25mb minimum.
>>
>>61173824
Lisp: comfy because you're approaching programming from the fundamentals of lambda calculus.

C: Comfy because you're approaching programming from the fundamentals of modern computer architecture.
>>
>>61173764
I've applied to lots of jobs and landed a pretty good one (so I think I'm okay at searching) and usually you'll see Scala jobs if any, but some people don't call that "proper lisp". I might look in different places than most but for "proper lisp" languages, I see Haskell jobs more often to be completely honest.

>>61173788
In the C standard for shifting:
>If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undefined.
So my guess is if long happens to be 32 bits, that code isn't executed anyway and it's a trick to get rid of compiler warnings/errors for that line.
>>
>>61173824
Pretty sure you're just a hipster.
Lisp wouldn't be comfy if it was super popular.
>>
>>61173824
>Lisp
>comfy
(((((((((((((((((((((((((((uguu am i kawaii desu anon-chan?))))))))))))))))))))))))
>>
>>61173933
Invalid.
Post actual code you dumb fuck.
>>
>>61173879
why isn't there a computer yet that's an implementation of lambda calculus instead of being an implementation of a turing machine
can you imagine how fucking comfy it would be if your assembly looked like this
\x.(\y.x)
>>
>>61173946
>\
disgusting
>>
>>61173957
give me one good reason that a backslash is not a reasonable stand-in for a lambda
>>
>>61173946
What does a physical model of the lambda calculus look like?
>>
>>61173974
feminine
>>
>>61173974
I don't know but it would probably involve structuring particles into some kind of network
>>
>>61173946
DDG "Lisp Machine".
>>
File: baka.jpg (55KB, 555x720px) Image search: [iqdb] [SauceNao] [Google]
baka.jpg
55KB, 555x720px
>>61173974
>>
reminder that good programmers use small keyboards

fullsize keyboards are for casuals who don't know how to use them efficiently
>>
>>61173769
it's for having better performances that immutable lists are the default
>>
>>61173769
No you don't.
If you want a singly linked list with one element inserted at the front, you need only hold a pointer to the old list which, being immutable, won't change.
>>
>>61173755
the point of a list is so you can insert and remove elements............ why not just use a goddamn fucking array instead of an immutable list
>>
>>61174176
>the point of a list is so you can insert and remove elements
No
>>
I'm working on a web server. Should it use web sockets?
>>
>>61174192
explain how an immutable list is better than an immutable array
>>
>>61174176
>the point of a list is so you can insert and remove elements
no. the point of a list is sequential access/parsing
>>
>>61174176
You don't get how computation works in lisp at all
>>
>>61174202
s/list/array
>>
>>61174201
You can prepend to it in O(1) time
You can get its tail in O(1) time
>>
>>61174201
It really isn't
>>
I'm working on a pair programming extension to a text editor using webrtc.
>>
>>61174224
array is better for random access

>>61174201
memoization, for example.
>>
>>61174074

Most time spent programming is not spent typing up code. Keyboard efficiency is irrelevant.
>>
>fucking lispfags
lmao
>>
>>61174265
cbaby pls go
>>
>>61174258
wrong. you a probably confusing either (or both) software engineering or algorithm design and analysis with programming.
>>
>>61174267
>lisp
impure weakly typed garbage
>>
>>61174265
Lisp is the most programmingful powerlanguage.
>>
>>61174280
explain what's weak typing. many lisp are typed. C is actually one of the very rare programming languages who are truly weakly typed.
>>
>>61174281
[crysis voice] maximum autism
>>
>>61174298
>[crysis voice]
maximum autism
>>
>>61174314
>maximum autism
autism
>>
>>61173886
>it's a trick to get rid of compiler warnings
Yes. Doesn't make it less undefined though.
This is the kind of thing that should make you doubt how good your source is.
>>
>>61174265
I don't program in lisp unless some outside force causes me to, but I'll defend it from retards who don't understand it.

>>61174280
Yeah, I don't like that about it either

>>61174291
Not him, but most lisps that people use besides scala are weakly typed though

>>61174274
Wonder what you think "programming" is then
>>
>>61174326
>scala
>a lisp
Explain.
>>
>>61174326
>Wonder what you think "programming" is then
implementing interfaces and alrogithms (in code, obviously).
>>
>>61173971
Because λ is already a good stand-in for "lambda".
>>
>>61174201

>immutable array
Gross! Just use a mutable, resizable vector for everything unless another data structure is required. Append in amortized O(1) time, get any element in O(1) time, set any element in O(1) time, iterate without tons of cache misses...

>>61174274

Most of my time is spent consulting documentation... or do you keep each and every library that you use in your head at all times? Incidentally, a programming tends to involve software engineering. You have to have a general idea of how you want the program to look before you start writing code. Just making shit up as you go doesn't tend to scale well.
>>
>>61174321
Sure it does. In his code the behavior is well defined because the conditional doesn't execute in situations where it's undefined behavior. In fact, even if it was executed at sizeof == 4, it's still defined behavior by the C standard since it just zeroes out the value.
>vacated bits are filled with zeros.

>>61174352
I'm of a similar mind with that, see my post >>61173886

>>61174362
I find it hard to believe that you're limited by typing.
>>
File: 1483899740618.png (276KB, 600x558px) Image search: [iqdb] [SauceNao] [Google]
1483899740618.png
276KB, 600x558px
>>61174423
>mutable

>impure
>>
>>61174408

Not on any standard keyboard.
>>
>>61174433

Gotta go fast, Anon.
>>
>>61174454
optimisation can be done by a compiler too
>>
>>61174423
>>immutable array
>Gross
not any more gross than an immutable list
>>
>>61174469

Compilers can't optimize poor algorithmic complexity (O(n) for arbitrary element access in a linked list), nor can they optimize poor cache utilization that is inherent in linked lists.

>>61174483

The immutable part is what's gross.
>>
File: wtf.gif (7KB, 599x101px) Image search: [iqdb] [SauceNao] [Google]
wtf.gif
7KB, 599x101px
Could someone help me out with pic related?
>>
>>61174544
>compilers can't optimise pure code
>pure code can't represent impure phenomena
>>
>>61174563
what don't you understand? we can help you, we'd rather just not spoonfed you
>>
>>61174574
>lists
>""""""""""""""""pure""""""""""""""""
>>
>>61174597
>pure integers
>"""""""""""pure""""""""""
>>
>>61174608
``unmatched quotes''
>>
>>61174617
"
>>
>>61174574

Compilers can't optimize your poor choice of data structures.
>>
>>61174668
You're retarded.
>>
>>61174563
(defun ! (n)
(cond ((zerop n) 1)
(t (* n (! (- n 1))))))

(defun e^x (x n)
(loop repeat n for i from 0
sum (/ (expt x i) (! i))))
>>
>>61174563
fn fac(n: i32) -> f64 {
if n < 2 {
1.0
} else {
(1..(n + 1)).product::<i32>() as f64
}
}

fn exp(x: f64) -> f64 {
(0..11).map(|i| x.powi(i) / fac(i)).sum()
}
>>
>>61174679

And how do you defend this claim?
>>
>>61174710
Holy fucking shit that's ugly language!
>>
>>61174585
I don't understand how x = 1 results in Euleurs Number. I wrote each step down on paper, but it didn't result in the correct answer:
x = 1

1+x+x^2= 3
2!+x^3= 3
3!+x^4= 7
4!+x^5= 25
5!+x^6= 121
6!+x^7= 721
7!+x^8= 5041
8!+x^9= 40321
9!+x^10= 362881
10!+x^11= 3628801
= 3,6 x 10^-16
>>
>>61174717
I don't need to convince you, everyone else is already aware.
>>
>>61174727
I don't think you're doing what the equation says. I don't see the division in each term.
>>
>>61174710
>fn fac(... }
in Haskell this is just
fac x = product [1..x]
>>
>>61174745
Or is the '/' used to seperate each term?
>>
>>61174749
What if i want fac 0?
>>
>>61174727

each term is

[x to the kth power] divided by [k factorial].
>>
>>61174759
What if you want fac 0?

>>61174727
>+
>>
>>61174759
This, haskellfags really are retarded.
>>
>>61174777
0! = 1
The haskell code doesn't account for that, making it useless
>>
>>61174808
It doesn't?
That's news to me.
I guess my REPL is broken.
>>
>>61174808
> product [1..0]
1
>>
>>61174733

So in other words, you have no argument.
>>
>>61174774
Holy shit, I guess I really am retarded.
Thanks anon.
>>
>>61174848
Yes, I'm not arguing, I'm declaring.
>>
>>61174816
>>61174839
Ah, i was wrong about the behaviour of [x..y] when x>y
>>
>>61174759
>>61174779
>>61174808
fucking imperativefags don't ever bother to check what they're saying, makes sense considering the kind of programming they endorse
>>
>>61174862
[x..y] | x > y = []

product [] = 1
>>
If you've never used an indexed monad, you may not post in /dpt/.
>>
>>61174848
Doesn't make him any less right.
>>
>>61174681
>>61174710
lmao in haskell, this is just
exp x n = sum . map (\k -> (x^k) / (fact k)) [0..n]
where fact n = product [1..n]
>>
>>61174942
>muh "moan ads"
>>
>>61174949

Well he was wrong by default. He made a claim, and did not substantiate it. I can declare that the Earth is flat all day long, but that won't make it true.
>>
>>61174969
you could just do fact inline
also you mean ( ) not .
>>
>>61174563
function exp(x) {
sum = 0
for n = 10 loop until 0
sum += (x^n)/(n!)
}


retards like >>61174710
forgot that 0! = 1 and x^0 = 1
>>
>>61175035
x^0 = 0, you absolute idiot.
>>
>>61175049
Quick, delete this post!
Before they call you a retard!
>>
>>61172149
Do I have to write stuff like
p1.getPos().getX()
to achieve incapsulation in C++, or is there a better way?
>>
>>61175049
since this is /dpt/, i'm legitimately unsure if you are retarded or pretending to be retarded.
>>
>>61175081
Write a lens library
>>
>>61175081
>is there a better way
You can make a function that calls the member function getX() on the pos directly.
But basically no there's no better way if you want 'encapsulation'.
>>
C++ vs GO: GO!
>>
>>61175160
how can you favor Go over C++ you dipshit
>>
Why do people dislike Javascript over things like python?
>>
>>61175160
Go is Django++
>>
>>61175160
sepples has one of the ugliest syntax
go somehow manages to be even worse
Program in either one of them is losing
>>
>>61175081

In C++ especially, you don't want that degree of encapsulation. If you can read and write x then just make x public, don't abstract that bullshit if the point of your language is to be close to the metal.
>>
>fac(100)
thread 'main' panicked at 'attempt to multiply with overflow'
>>
>>61175173
because javascript is genuinely awful in every way, unlike python which is bad in only a few
>>
>>61175229
Doesn't happen in Haskell
>>
>>61175229
meant to reply to >>61174710

>>61175242
Yeah Haskell uses Integer which is arbitrary precision

>>61175232
Care to name some examples? Not saying I fully disagree but a lot of people say this who can't back it up.
>>
>>61175172
you misunderstand
>>
>>61172277
>Post a better string reversal in C.
>void reversal(char* r){
> size_t len = strLen(r);
> char* f = r+len-1;
> for(;r<=f;r++,f--){
> *r += *f;
> *f = *r - *f;
> *r -= *f;
> }
>}
Explain your variable naming convention.
>>
>>61175058
>>61175102
It's undefined.
>>
>>61175435
x^0 is 1

In the case of x = 0, you could argue either way, but mathematicians generally agreed 0^0 = 1 as a convention about 20 years ago
>>
>>61175049
pls sir do the nedful and delt
>>
>>61175279

The type system is awful. The only numeric type is a float. Both null and undefined type exists, yet typeof null is object. Dynamic typing isn't inherently bad but with type juggling it certainly is. == is useless and + can be completely bizarre and backwards.
Variable scoping is awful. The only limit you can have on scope is the function; block scope does not exist. If you forget to declare with var, you have a new global.
Prototypal inheritance is a powerful model, but Javascript's take is ass-backwards. Javascript's attempts to resemble Java just hide its true nature and make it unnecessarily convoluted.
Basically you can't do anything without something awful happening.
>>
whats stopping me from making a c program and then but then just writing the entire thing as inline assembly for maximum performance
>>
File: archive_cpp.jpg (283KB, 637x532px) Image search: [iqdb] [SauceNao] [Google]
archive_cpp.jpg
283KB, 637x532px
making a 4chan thread archiver (with updates for living threads) because of a "pro/g/ramming challenges.jpg" (5 months ago)
>>
>>61175504
NOT PORTABLE
>>
>>61175447
It is more elegant to consider so and happens to be consistent with set theory but doesn't change the fact that the function is not continuous. My point is the only retarded guys were those calling him retarded.
>>
>>61175501
also, semicolon insertion is the bane of my fucking life
>>
>>61172639
Does the compiler figure out that it's a swap as it would with xorswap or a normal temp value swap?
>>
>>61175519
No, x^0 is 1, and not undefined.
Even the 0^0 exception is defined as 1, it's accepted now, it makes more sense that way anyway.
Think about it

x^4 = the product of 4 x's
x^2 = the product of 2 x's
x^1 = the product of 1 x
x^0 = the product of 0 x's (1)
>>
new thread
>>61175574
>>
>>61175504
Nothing. Except it's kinda pointless to take a C compilation and use the disasm output and inline. That's just like writing C with force inline.
What you should do is write a C version and spot the issues in your code and improve them through leveraging your optimizer or writing a asm replacement where applicable.
>>
>>61175389
>variable naming convention
depends on project and domain

I don't speak much C, but I think your solution is the optimum solution
most other languages would reallocate the whole string
think we can get a benchmark game going on this?
>>
>>61175435
you are being way, way too retarded
the point is solving the problem

show me a language whose standard math lib doesn't return 1 or pow(0)

you made my tea bitter
>>
>>61175659
>be ignorant
>call others retarded
I'm glad I made your day shittier.
>>
>>61175749
you are right, sorry
>>
>>61175749
not him but reminder that just because x^0 is undefined where x = 0 does not make x^0 undefined
>>
>>61172277
I like yours, but I think mine is fancier.

/* reverse the string */
void
reverse(char *str)
{
char c;
int i, j;

for (i = -1; (c = str[i+1]) != '\0'; ++i) ;

for (j = 0; j < i; ++j, --i) {
str[j] = str[j] ^ str[i];
str[i] = str[j] ^ str[i];
str[j] = str[j] ^ str[i];
}
}
>>
>>61175504
literally just write assembly
>>
>>61175605
see >>61175839
>>
>>61175839
>iterating one byte at a time
>accepting this brainlet-tier performance when there are such things as words
pleb
>>
>>61172777

see >>61175839 for xor swap implementation
>>
>>61175894
but anon, I'd have to spend a lot more time on it if I wanted to compare words. Also it wouldn't look nearly as nice/simple. It's just a 4chan exercise, not code for nasa
>>
>>61175946
>compare words
Why not go full simd?
>>
>get burned out and decide to spend the afternoon installing gentoo on a spare toastertop i have
>Have to make install 176 packages
>cant just watch tv idly anymore
>back to work i go

So how's your day going, /dpt/?
>>
>>61175946
>>61176023
the point is the version that uses strlen finds the end of the string by iterating over words because that's how strlen works
even though finding the end yourself is cooler it's unfortunately less efficient for this reason
>>
>>61175839
>xor swap
sure is summer
>>
>>61172924
0 because i'm not a fag
>>
>>61173197
only brainlets despise them.
>>
>>61172649
I hate children
what about a fucking string reversal function has to be readable, you dip shit? it's never going to change
no one has to touch it ever
don't talk about what you know nothing
>>
>>61172698
that's exactly the same algorithm
you just made it worse
are you retarded?
give up programming
>>
>>61175839
lol
are you serious?
Thread posts: 338
Thread images: 21


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]
Please support this website by donating Bitcoins to 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
If a post contains copyrighted or illegal content, please click on that post's [Report] button and fill out a post removal request
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.
This is a 4chan archive - all of the content originated from that site. This means that 4Archive shows an archive of their content. If you need information for a Poster - contact them.