[ a / b / cf / cy / g / lain / un / pollitx ] [ wired / meta ] [ home / rules / faq / affiliates ] [ calculus / mebious ]

/g/ - Technology

Programming and Electronics
Name
Subject
Comment
File
Embed
Password (For file deletion.)

Mebious now up and running! Access the wired.

File: 1581460038602.png (503.48 KB, 934x1000, daily_programming.png)

 No.211[View All]

What are you working on, /g/?
53 posts and 27 image replies omitted. Click reply to view.

 No.459

File: 1608072096637.png (727.83 KB, 960x776, ece6c06fcbdb9dd0c7c4793cbd….png)

> tfw you want to go to sleep but you feel that you have *almost* solved that nasty problem
Sleep deprivation, here I come!

 No.460

>>459
I know what you mean, fug

 No.461

>>315

Goal forall n, n = 0 \/ n = 1 \/ n = 2 \/ n = 3 -> n - 3 = 0.
intros n Cs.
decompose [or] Cs; subst; reflexivity.
Qed.

 No.540

Rate my run-length encoding functions in OCaml. Here's the most simple:

let rec rle l =
match l with
| [] -> []
| h::t ->
match rle t with
| (h', n)::t' when h' = h -> (h, n+1)::t'
| t' -> (h, 1)::t'

And a somewhat more involved:

let rle l =
let rec iter c n l =
match l with
| [] -> [(c, n)]
| h::t ->
if h = c then iter c (n+1) t else (c, n)::(iter h 1 t)
in match l with
| [] -> []
| h::t -> iter h 1 t

 No.541

>>540
>Rate my run-length encoding functions
The first one is recursive in the obvious way, which is why it's "most simple". The second one still has a pending "(c, n)::" operation to perform after the "(iter h 1 t)" subcall, so unless OCaml rewrites this for you this is also recursive, despite the "iter" name. To get an iterative version with what are effectvely cons-style lists, you'll need to build a partial result in an accumulator and reverse the accumulator at the end, ensuring that the reversal operation is also iterative.

iter-is-still-recursive/10

 No.542

>>541
Sorry, hope you like this better:

let rle l =
let rec aux c n l =
match l with
| [] -> [(c, n)]
| h::t ->
if h = c then aux c (n+1) t else (c, n)::(aux h 1 t)
in match l with
| [] -> []
| h::t -> aux h 1 t

I don't like the full accumulator passing style because the extra reverse is often more costly than saving some returns to the stack.

 No.543

>>542
>I don't like the full accumulator passing style because the extra reverse is often more costly than saving some returns to the stack.
The recursive version performs a linear pass on the input list going up the stack, and a linear pass for the result list coming down the stack. The iterative version performs a linear pass on the input list to build the accumulator, and a linear pass for the result list to reverse the accumulator. The reversal phase is the same size as coming down the stack, so unless there is some OCaml peculiarity that intervenes, your cost assertion is false. Furthermore on large and poorly rle-compressible input lists the recursive version dies by overflowing the stack, while the iterative version keeps working.

renamed-not fixed/10

 No.544

>>543
Yes, if the list is that large, there's not much else to do other than moving the call stack to the heap. But for shorter lists, pushing three values to the stack is cheaper than constructing an extra cons cell for each element of the result.

 No.548

>>544
Does OCaml offer some way to write a conditional that tests whether the recursive version would blow the stack if it were to be run?

 No.550

>>548
It does not. But I know, Big Data and Machine Learning is the hip thing now, so here's your industrial strength run-length encoding:

let rle l =
let rec aux c n a l =
match l with
| [] -> List.rev ((c,n)::a)
| h::t ->
if h = c && n < max_int then aux c (n+1) a t else aux h 1 ((c, n)::a) t
in match l with
| [] -> []
| h::t -> aux h 1 [] t

 No.551

File: 1612907484109.jpg (4.16 MB, 2266x3173, rias2.jpg)

>>550
fixed/10

 No.572

Find songs by artist in bash

find_by_artist() {
find . -type f -print0 \
| xargs -0 exiftool -artist 2>/dev/null \
| awk -v RS='======== ' -v FS='\n' -v ORS='\0' \
'$2 ~ /'"${1}"'/ { print $1 }'
}

 No.578

>>357
Try writing a lexer. I'm not adept at making algorithms and this confused me. Try making something to recognize numbers, comments, strings, and a few key words from C. Just tokenize an input txt file.

 No.581

File: 1614371873438.png (17.35 KB, 800x500, 87617512_p0.png)

I wanted to try write a simple dependently typed program because I always just prove things but Coq can do this too. So here are the Fibonacci numbers. First, the specification of what it means for a number to be "Fibonacci", the proposition `fibonacci n m' says that the nth Fibonacci number is m:

Inductive fibonacci : nat -> nat -> Prop :=
| fib0 : fibonacci 0 0
| fib1 : fibonacci 1 1
| fibS n a b m (Ha : fibonacci n a) (Hb : fibonacci (S n) b) (Hm : a + b = m) : fibonacci (S (S n)) m.

This is straightforward, we know that the 0th number is 0 (fib0), the 1st is 1 (fib1), and the (n+2)th is m, if m is a + b where b is the (n+1)th number and a is the nth.

 No.582

File: 1614371892504.png (17.88 KB, 800x500, 87617512_p1.png)

>>581
Here is the program itself:

Definition fib n : { m | fibonacci n m } :=
let aux :=
fix f n :=
match n with
| 0 => (exist (fibonacci 0) 0 fib0, exist (fibonacci 1) 1 fib1)
| 1 => (exist (fibonacci 1) 1 fib1, exist (fibonacci 2) 1 (fibS 0 0 1 1 fib0 fib1 eq_refl))
| S (S n) =>
let (Xa, Xb) := f n in
let (a, Ha) := Xa in
let (b, Hb) := Xb in
let Hab := fibS n a b (a + b) Ha Hb eq_refl in
(exist (fibonacci (S (S n))) (a + b) Hab,
exist (fibonacci (S (S (S n)))) (b + (a + b))
(fibS (S n) b (a + b) (b + (a + b)) Hb Hab eq_refl))
end
in fst (aux n).

The first line says that fib takes an argument n, and produces such an m, that it is the nth Fibonacci number. (But only a single one and does not say anything about possible other such values.) `exist' is what builds the dependently typed value: its first argument is the property of the value, the second the value itself, and the third is the proof of the property holding for that value. The algorithm is a bit unusual because of Coq's type system. To keep the system logically sound, every algorithm must terminate. In many cases, Coq can automatically detect which argument is decreasing with each recursive call, but in case of the usual recursive definition of Fibonacci, it cannot. With a small trick it can, but that leads to another problem: it must also keep track of `n' to make sure that what it returns is indeed the `n'th number. For this reason both that and the usual iterative version, where it counts from zero up to n, fail type checking because Coq can't establish that the n going in the recursive call and the n coming back are the same.

 No.610

File: 1616484769382.jpg (68.13 KB, 550x814, cover.jpg)

Anyone else reading SICP2.0? My Scheme skills are a bit rusty but I am really happy to have an excuse to use it again.

 No.613

Does anyone else keep getting SERVFAIL on DNS requests for wizchan.org?

 No.614

File: 1617554820348.png (26.86 KB, 720x313, screenshot.png)

>>613
>wizchan
idk cause i don't post there but saw this on another board the other day

 No.615

>>614
Thanks.

 No.618

File: 1617913672356.png (122.3 KB, 529x482, richard_stallman.png)


 No.619

File: 1618001205173.png (302.39 KB, 1002x405, leah-rowe-defends-stallman.png)

>>618
>at the behest of proprietary software vendors
good to see no one's being paranoid about this whole thing

 No.620

>>619
What company would feel threatened by the FSF? They are pretty irrelevant.

 No.631

File: 1618346622484.jpg (171.17 KB, 1280x720, dumb.jpg)

>>610
I'm doing exercise 3.2 right now, and it told me to
> First, make an arithmetic that defines only addition, negation, and subtraction of vectors over a base arithmetic of operations applicable to the coordinates of vectors. Applying any other operation to a vector should report an error.
But if I make it throw an error with `(error "Unsupported vector operation:" operator)', it makes extend-arithmetic fail on zero?. If I return with #f instead of raising the error, it seems to work. I also had to register the `vector?' predicate.

I don't know if I am just not paying enough attention to the text or it really just throws you into deep water with the exercises.

 No.642

File: 1619125119964.png (7.05 KB, 364x118, Screenshot_2021-04-22_22-5….png)

Finished all the Scheme exercises on exercism. I did most of them around a year ago. Back then it would let you ask for code review on your solutions, which was pretty cool, I learned a few tricks from it. But now it wouldn't let me ask for it, I am not sure why, but it defeats the whole point of the site. Anyway I had it on my todo list, now I can finally cross it out.

 No.643

>>211
I just got into linux lately and I'm still learning basic bash commands lol. So I'm basically just working on being able to properly use a computer. Nothing big but feels good.

 No.646

>>643
That's pretty cool, bash can be really powerful. It's not perfect but it is damn useful.

 No.648

>>620
The GPL license is problematic for the corporate world. Pretty much all proprietary software depends on open source projects and GPL makes leeching off of open source software in proprietary projects difficult. Therefore any organized group that promotes FOSS is a threat. It's all about the money.
I don't know how organized the smear campaign against Stallman was. IMO most likely it was just useful fools who went after him.

 No.654

File: 1619978291383.jpg (87.72 KB, 300x440, 1387233973349.jpg)

>>642
I'm doing the C++ exercises now. They seem to have enough mentors to let me ask for reviews. We will see how it goes, I'm a bit afraid of C++ due to the memes of it being a Lovecraftian horror.

 No.660

>>654
I'm done with the main track of exercises, it was pretty disappointing. It's just 8 exercises and all of them are pretty simple, you don't really need to use any interesting C++ features. There are extra exercises and some of them are pretty interesting, but it's hard to get feedback on those. I'm still doing some of them but C++ is a mess, there's just so much to keep in mind while writing it, I don't think I'll using it in my free time much.

 No.662

>>648
Stallman is his own worst enemy, but his autism made him more effective up until recently.

 No.667

Does kind.moe seem to be down for anyone else? I keep getting
>Index of /
>Apache/2.4.29 (Ubuntu) Server at kind.moe Port 443

 No.670

File: 1621491198573.gif (1.82 MB, 360x344, wirechan-on-the-left-kind-….gif)

>>667
Yes, it wasn't working at all yesterday and now there's a message that they are working on it. In the meantime you can visit the bunker: https://anon.cafe/kind/

 No.687

File: 1622800542982.jpg (1.62 MB, 3532x5000, 08992f0f1973102866a332ae43….jpg)

A big thank you for helping out with /kind/!

 No.688


 No.689

File: 1622885586667.jpg (26.29 KB, 655x461, 1455647766593.jpg)

Last night I was trying to figure something out but had no success, I couldn't think of anything. So I turned off my computer and started to prepare for bed and of course suddenly all kind of new ideas flooded my head…

 No.690

File: 1623049902517.gif (1000.05 KB, 495x281, akari.gif)

>>670
https://anon.cafe/kind/res/46.html#122
Looks like the troubles are not over yet…

 No.691

>>690
I don't use anon.cafe due to their captcha/bypass nonsense. Please post the following in https://anon.cafe/kind/res/46.html

>>122
>due to excessive CPU usage
You were already told on kind.moe in the thread with 45 replies about the Date and expires timestamps in captcha response headers. Furthermore, in scheduleHandler.js:expiredCaptcha you have:

function expiredCaptcha(immediate) {
if (immediate) {
checkExpiredCaptchas();
} else {

schedules.expiredCaptcha = setTimeout(function() {
checkExpiredCaptchas();
}, captchaExpiration * 1000 * 1);

}
}

Notice the
>captchaExpiration * 1000 * 1
in setTimeout. Never set captchaExpiration to 0.

Separately, from Readme.md:
>* `noReportCaptcha`(Boolean): disables the need for captcha when reporting.

 No.692

>>691
Do you think it is the captcha expiration that causes the excess load? It does not make sense to me, since the client was waiting 256 seconds, does the server just make new captchas without the client side asking for one?

 No.693

>>692
>Do you think it is the captcha expiration that causes the excess load?
It is merely one item to check off the list.

>It does not make sense to me

>does the server just make new captchas without the client side asking for one?
No. The scheduleHandler has an expiration rescanning loop in expiredCaptcha that runs on a timeout of
>captchaExpiration * 1000 * 1
Notice that the callee, checkExpiredCaptchas, ends by handing off to expiredCaptcha again.

 No.694

File: 1623319069965.jpg (996.58 KB, 1500x1200, calne_ca1.jpg)

I plan on installing Gentoo on a spare machine for the first time in order to learn more about linux.

 No.695

>>694
Exciting! I wish I could Linux for the first time again lol

 No.697

>>694
unless youre getting a job on that field spend that time doing something productive for yourself

Trust me the gentoo rabbit hole its deep

 No.698

>>697
Well yeah, I had the great idea of trying it first time on my nearly 20y/o thinkpad. So compiling the kernel failed after 15hours and 40minutes and I have absolutely no idea what to do about it.
I still don't feel like it was for nothing.

I am about to get a job in this field, but is it really that deep? Everything I heared from Gentoo lately was something like
>Basically the optimization isn't worth it anymore because of fast computers / the compiling time makes it even
or:
>You're already using arch (actually artix) so there isn't that much anymore you're going to learn through getting into gentoo

I thought both were invalid arguments, but it's surprising to hear the opposite.

 No.736

Should I learn Rust? Is it really going to replace C and C++?

 No.746

File: 1633346167685.png (24.63 KB, 1071x455, Screen Shot.png)

https://www.php.net/manual/en/features.file-upload.errors.php
>UPLOAD_ERR_INI_SIZE
>Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini

when trying to post in >>>/a/12
file size: 2780883
examples of posts over 4MB: >>322 >>324 >>551

 No.747

>>746
Obscure technical searches lead me to underground chans. nice to know you all continue to exist. please keep allowing indexers to crawl you so this will happen in the future, thank you.

 No.748

>>747
Welcome, friend.

 No.749

Can we get an admin answer to >>746 ? Is it misconfiguration or has the file size limit been lowered?

 No.750

>>749
Filesize limit was lowered.

 No.751




[Return][Go to top] [Catalog] [Post a Reply]
Delete Post [ ]
[ a / b / cf / cy / g / lain / un / pollitx ] [ wired / meta ] [ home / rules / faq / affiliates ] [ calculus / mebious ]