There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

WindowsEnjoyer , in D or d come on

OMZ and TAB gang raise up!

PapstJL4U , in It’s a game for kids!
@PapstJL4U@lemmy.world avatar

Before studying CS, I recognized it as ‘the bioware puzzle’. They were probably copying their own scribbles fron back then.

Haskell was the hardest, but it looked the most beautiful.

lugal ,

Haskell was the hardest, but it looked the most beautiful.

That pretty much sums that language up

DarkenLM ,

Strange. I find the language hideous, most likely because it resembles math, or maybe because I'm already used to the C-like syntax.

lugal ,

Haskell is beautiful because it resembles math

xigoi ,
@xigoi@lemmy.sdf.org avatar

It’s also beautiful because it doesn’t have C-like syntax.

mindbleach ,

Functional programming flips your brain around backwards, but shader programming will turn it inside-out.

manpacket ,

For more brain flipping try looking into hardware description languages (Verilog) or proof assistants (Coq).

TheBananaKing ,

In order to write a haskell program, you must first write the corresponding haskell program.

lugal ,

And in order to do that, you have to imagine sisyphus happy

Knusper ,

<span style="font-weight:bold;color:#795da3;">hanoi </span><span style="font-weight:bold;color:#a71d5d;">:: Integer -> </span><span style="color:#323232;">a </span><span style="font-weight:bold;color:#a71d5d;">-> </span><span style="color:#323232;">a </span><span style="font-weight:bold;color:#a71d5d;">-> </span><span style="color:#323232;">a </span><span style="font-weight:bold;color:#a71d5d;">-></span><span style="color:#323232;"> [(a, a)]
</span><span style="color:#323232;">hanoi 0 _ _ _ </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#0086b3;">[]
</span><span style="color:#323232;">hanoi n a b c </span><span style="font-weight:bold;color:#a71d5d;">=</span><span style="color:#323232;"> hanoi (n</span><span style="font-weight:bold;color:#a71d5d;">-</span><span style="color:#0086b3;">1</span><span style="color:#323232;">) a c b </span><span style="font-weight:bold;color:#a71d5d;">++</span><span style="color:#323232;"> [(a, b)] </span><span style="font-weight:bold;color:#a71d5d;">++</span><span style="color:#323232;"> hanoi (n</span><span style="font-weight:bold;color:#a71d5d;">-</span><span style="color:#0086b3;">1</span><span style="color:#323232;">) c b a
</span>

From here: www.rosettacode.org/wiki/Towers_of_Hanoi#Haskell

DumbAceDragon , (edited )
@DumbAceDragon@sh.itjust.works avatar

https://media.tenor.com/1bIptSWki_kAAAAd/unintelligible.gif

Edit: I understand it now. That first line is just a really weird way to define a function.

Knusper ,

Welp, imma try myself at an explanation. Mostly cause I haven’t written Haskell in a while either.

So, that first line:


<span style="font-weight:bold;color:#795da3;">hanoi </span><span style="font-weight:bold;color:#a71d5d;">:: Integer -> </span><span style="color:#323232;">a </span><span style="font-weight:bold;color:#a71d5d;">-> </span><span style="color:#323232;">a </span><span style="font-weight:bold;color:#a71d5d;">-> </span><span style="color:#323232;">a </span><span style="font-weight:bold;color:#a71d5d;">-></span><span style="color:#323232;"> [(a, a)]
</span>

…actually only declares the function’s type.

In this case, it’s a function that takes an Integer and three values of a generic type a and then returns a list of tuples of those same as.
So, those as are just any types representing the towers. Could be strings, integers, custom data types, whatever. The returned tuples represent movements between towers.

Following that are actually two definitions of the function.

The first definition:


<span style="color:#323232;">hanoi </span><span style="color:#0086b3;">0</span><span style="color:#323232;"> _ _ _ </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#0086b3;">[]
</span>

…is the recursion base case. Function definitions are applied, whenever they match, being evaluated top-to-bottom.

This line specifies that it only matches, if that first Integer is 0. It does not care what the remaining parameters are, so matches them with a wildcard _.
Well, and to the right side of the equals sign, you’ve got the return value for the base case, an empty list.

Then comes the more interesting line, the recursion step:


<span style="color:#323232;">hanoi n a b c </span><span style="font-weight:bold;color:#a71d5d;">=</span><span style="color:#323232;"> hanoi (n</span><span style="font-weight:bold;color:#a71d5d;">-</span><span style="color:#0086b3;">1</span><span style="color:#323232;">) a c b </span><span style="font-weight:bold;color:#a71d5d;">++</span><span style="color:#323232;"> [(a, b)] </span><span style="font-weight:bold;color:#a71d5d;">++</span><span style="color:#323232;"> hanoi (n</span><span style="font-weight:bold;color:#a71d5d;">-</span><span style="color:#0086b3;">1</span><span style="color:#323232;">) c b a
</span>

This line matches for any remaining case. Those small letter names are again wildcards, but the matched value is placed into a variable with the provided name.

And then, well, it recursively calls itself, and those ++ are list concations. This line’s only real complexity is the usual Tower Of Hanoi algorithm.

neonblade , in It’s a game for kids!

Example for stack

ram , in D or d come on

There are two Linux paradigms that I consider stupid. One is the use of centralized software repositories managed by the distro instead of individual developer maintained installers. The other one is file system case sensibility. They already admitted defeat on the first one with the rise of containerised applications. I wonder how much longer they’ll keep the charade on the second one.

charlotte ,

Sorry, but you’re plain wrong on your first issue. Getting all your packages from one source is one of the biggest upsides of Linux.

onlinepersona ,

Pretty hilarious for mac users, of all people, to complain about centralisation. Like, don’t you live in a walled garden?

EddoWagt ,

Indeed, but I’m sure we can agree that it’s pretty stupid for every distro to maintain its own repo. That’s a lot of duplicate work, which could be spend on more useful things. Luckily flatpak is well on its way to change that

charlotte ,

Hm… But different distros have different philosophies (not just) about updates. That’s part of why people choose a specific distro.

Theres still plenty speaking against flatpak (larger sizes, problems with GTK/qt themes, and it’s only meant for GUI applications - you still need a separate system for the kernel and lower-level/cli tools. And frankly, that makes flatpak unusable to me, because the purpose of a centralized package management system is not having duplicate systems).

So in short: y’all are gonna pry pacman from my cold, dead hand.

tslnox ,

The same goes for me, but with Portage, brother.

EddoWagt ,

I’m not against distros as a whole, some extra work will be inevitable because people have different preferences, but it feels like a waste having a Firefox package for arch, ubuntu, fedora and Debian while essentially all being identical. Indeed flatpak isn’t perfect yet, but it works great for me and it’s steadily improving

MJBrune ,

I have a third one for you. Not being able to pick where things install. Everything installs to the os disk. Terrible idea.

CannotSleep420 , in It’s a game for kids!

I took a test once where one of the questions was to solve the tower of hanoi with 2 pegs and 3 disks.

jackie_jormp_jomp ,

That’s just unfair

CannotSleep420 ,

I was lucky enough to figure out that it was a trick question, but I second guessed every answer I put on tests and homework for that professor ever since.

learningduck ,

How is that possible? is it has a different rule?

CannotSleep420 ,

No, it was a trick question. The test taker was supposed to pick up on that.

odium , in It’s a game for kids!

It’s even called tower of Hanoi because of the Vietnam war flashbacks.

steltek , in D or d come on

Here’s how to fix this[+]

Create $HOME/.config/user-dirs.dirs with

XDG_DOWNLOAD_DIR=“$HOME/downloads”

You may need to logout/in for things to reread this file.

The full list of keys is:

  • XDG_DESKTOP_DIR
  • XDG_DOWNLOAD_DIR
  • XDG_TEMPLATES_DIR
  • XDG_PUBLICSHARE_DIR
  • XDG_DOCUMENTS_DIR
  • XDG_MUSIC_DIR
  • XDG_PICTURES_DIR
  • XDG_VIDEOS_DIR

+: Since this is Linux, this is a fix for many but not all cases.

lastweakness ,

XDG User dirs are cool, i agree. But that’s not really the problem here

starman , (edited ) in D or d come on
@starman@programming.dev avatar

So you type cd D tab and it brings you to Documents

Asswaterpirate , in D or d come on

cd snuts

zlatko ,

did you mean smuts?

CodexArcanum , in D or d come on

I love how many people brought up the Turkish “I” as if everyone here is on the Unicode steering committee or just got jobs for Turkish facebook.

I, an English speaker, have personally solved the problem by not having a Turkish I in the name of my Downloads directory, or any other directory that I need to cd into on my computer. I’m going to imagine the Turks solve it by painstakingly typing the correct I, or limiting their use of uppercase I’s in general.

In fact, researching the actual issue for more than 1 second seemingly shows that Unicode basically created this problem themselves because the two I’s are just seperate letters in Turkic languages. …wikipedia.org/…/Dotted_and_dotless_I_in_computin…

If you nerds think this is bad try doing Powershell for any amount of time. It is entirely case-insensitive.

yum13241 ,

Why the FUCK did they make characters that look the same have different codepointers in UNICODE? They should’ve done what they did in CJK and make duplicates have the same codepointer.

Unicode needs a redo.

Tranus ,

Well letters don’t really have a single canonical shape. There are many acceptable ways of rendering each. While two letters might usually look the same, it is very possible that some shape could be acceptable for one but not the other. So, it makes sense to distinguish between them in binary representation. That allows the interpreting software to determine if it cares about the difference or not.

Also, the Unicode code tables do mention which characters look (nearly) identical, so it’s definitely possible to make a program interpret something like a Greek question mark the same as a semicolon. I guess it’s just that no one has bothered, since it’s such a rare edge case.

yum13241 ,

Why are the Latin “a” and the Cryilic “a” THE FUCKING SAME?

mrpants ,

In cases where something looks stupid but your knowledge on it is almost zero it’s entirely possible that it’s not.

The people that maintain Unicode have put a lot of thought and effort into this. Might be helpful to research why rather than assuming you have a better way despite little knowledge of the subject.

yum13241 ,

When it’s A FUCKING SECURITY issue, I know damn well what I’m talking about.

mrpants ,

Again you do not because the world consists of more than your interests and job description.

yum13241 ,

I know damn well what I’m talking about when someone could get scammed on “apple.com” but with a Cyrillic A.

mrpants ,

You know the problem but not the set of reasonable or practical solutions.

Anyways I and l look identical too in many fonts. Should we make them the same letter?

yum13241 ,

No, but that’s what Unicode does.

The solution is to force font creators to be fucking reasonable, just like how the Cyrillic A looks exactly like the Latin A. They are the same letter. The letters L and I are totally different (in handwriting at least)

They already did that for CJK. Make characters that look the same in handwriting b have be same codepointer.

kattfisk ,

I and l also look identical in many fonts. So you already have this problem in ascii. (To say nothing of all the non-printing characters!)

If your security relies on a person being able to tell the difference between two characters controlled by an attacker your security is bad.

yum13241 ,

The problem is when you can register “apple.com” with the Cryillic A, fooling many.

The I l issue is caused by fonts, not by ASCII.

kattfisk ,

You really can’t though. For several reasons. Which would have been apparent to you had you bothered to actually create your example link to аpple.com or to understand this problem.

MonkderZweite , in D or d come on

You’ve come from Windows and have brought dangerous expectations.

naught ,

MacOS has a case insensitive file system. It causes me untold grief

sysadmin420 ,

Is a 40 year old it guy who love linux, wat

Macos is case insensitive?!

sudo ,

OSX offers both case sensitive and case insensitive filesystems

sysadmin420 ,

Wow, I figured it’d be case sensitive, crazy, gotta make it more windows like I guess.

naught ,

Defaults to insensitive and if you want to change it you have to reformat 🥲

example ,

I’ve been using case insensitive fs on macOS for years and the only software having issues with this is onedrive.

can’t say i’m surprised.

naught , (edited )

I have issues with Docker a lot. Example: Rename a file from “File.js” to “file.js” in a dependency and it’s like something caches the old name so even when I redownload or install that dep it tries the old name and fails to find the file. Might just be me and my tomfoolery

example ,

if you’re renaming from File.js to file.ts, which is also changing suffixes instead of just capitalization, then that couldn’t be explained by case sensitivity, unless it was a typo and you meant File.js to file.js

naught ,

Yep typo thanks

kattfisk ,

This is likely because docker runs Linux in a VM on MacOS right?

We’ve had similar problems with stuff that works on the developers Mac but not the server which is case sensitive. It can be quite insidious if it does not cause an immediate “file not found”-error but say falls back to a default config because the provided one has the wrong casing.

naught ,

Yeah exactly. And I mount the volume to the local directory so they try to sync both ways. It’s a real mess. The solution is currently to: not fuck up the file name casing in the first place. lol

joyjoy ,

The same issue happens with git (on windows). The file system says they’re the same file and they haven’t changed, so you have to manually tell the program the file changed. With git, you’d run git rm --cached &amp;&amp; git add . On docker, you could just do a non-cached build via docker build . --no-cache

steakmeout ,

That isn’t true.

naught ,

Which part? I’d love to switch if there’s no reformatting, and if your exception is with the first part, I’d ask for some evidence. All of my mac machines arrived brand new, case insensitive. Granted that’s only 3 so far, but it’s a smattering from 2019 onward. All the literature online points to this being the default too

Honytawk ,

Why would case sensitive path names be considered dangerous?

colonial ,
@colonial@lemmy.world avatar

I don’t know about dangerous, but case-insensitive Unicode comparison is annoying, expensive and probably prone to footguns compared to a simple byte-for-byte equality check.

(And yes, all modern filesystems support Unicode. Linux stores them as arbitrary bytes, Apple’s HFS uses… some special bullshit, and Windows uses UTF-16.)

MenacingPerson ,

Meanwhile fishshell:

lnee ,

so if linux stores file names as arbitrary bytes them could I modify a ext4 fs to include a / in a file name

kattfisk ,

If you did it would likely break something as it’s one of only two characters not allowed in a file name (the other being null).

You can do a lot of funky stuff within the rules though, think about control characters, non-printing characters, newlines, homographs, emojis etc. and go forth and make your file system chaos!

muntedcrocodile , in D or d come on
@muntedcrocodile@lemmy.world avatar

Doesn’t fish basically fix this?

pgp ,

This is not a bug, it doesn’t need to be fixed.

avonarret1 ,

It’s funny that you’re getting down voted for telling the truth. Nothing to be subjective about either. 😅

muntedcrocodile ,
@muntedcrocodile@lemmy.world avatar

Would hope so

mindbleach ,

There are solid technical reasons whenever someone’s computer doesn’t work the way they expect.

They don’t matter.

The software can do what people want, or it can be wrong.

pgp ,

Wrong, it does matter. Just because it’s not working as you want, doesn’t mean it’s not working as expected.

mindbleach ,

It literally does.

xoggy ,
@xoggy@programming.dev avatar

You can set bash or zsh to case-insensitive tab completion as well.

muntedcrocodile ,
@muntedcrocodile@lemmy.world avatar

Seems like poor configuration either default or not

d_k_bo ,
Astaroth ,

yeah Fish tab completion works, but one thing I’ve noticed though is that tab completion for wrong case only works if there’s no option with the correct case

e.g. if I have Downloads and Downloads2 then d with tab completion will become Downloads, but if I have Downloads and downloads2 it will tab complete to downloads2 and D will complete to Downloads

I’ve been meaning to look through the Fish documentation to see if I can change that and fuzzy search for history but never got around to it

willya , in D or d come on
@willya@lemmyf.uk avatar

You know you prefer the D

Moc ,

OP can definitely handle a bigger D

newIdentity , in D or d come on

Use Zsh or Fish and tab completion.

janAkali ,

Or better yet, use z or zoxide:
“z down” will fuzzy match the “~/Download” folder.

words_number ,

This is the way!

seitanic ,
@seitanic@lemmy.sdf.org avatar

Yeah, if that’s the only reason, changing your shell is overkill.

Astaroth ,

Never used or heard of it before but apparently zoxide is only for cd command, do you happen to know if there’s some fuzzy match for in general?

At the moment what I do is history foo | grep -i “bar”

krey , in D or d come on

If you want to keep case sensitive completion, you can symlink it. It’s your home dir. Make yourself comfortable.

Morphit ,
@Morphit@feddit.uk avatar

There’s no place like ~.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines