Ramda By Example, Lesson 1

preview_player
Показать описание
I've recently started using Ramda, the functional programming library. Here's what I've learned.
Рекомендации по теме
Комментарии
Автор

I'm wondering if using regex might be a better solution than hardcoding a GROUP_LEN index?

andrewjarrett
Автор

I need therapy after watching this video. Wasted 20 years of my life doing object oriented programming. This shit is AWESOME!

ketankshukla
Автор

Did ramda R.chain changed? I had to switch from: (on 3:37 min)
const addLabel = R.chain(R.append, R.head); // this fixed the error I got

henriqueferreira
Автор

That's awesome, but seems pretty much "write once, never read"

DiegoHaz
Автор

The problem with functional programming is that in real life projects it often builds complex structures that are very difficult to read back. The same happens with regular expressions, you can write them but you cannot read them easily. Long time ago the APL language had the same characteristics. You could write very sophisticated programs in just one line of symbols, but it was a real challenge to understand them afterwards.

jean-francoisbouzereau
Автор

Nice, but i don't see the advantage over using native functionality, where it can be done completely functional:

Object.entries({
'group1-perm1': true,
'group1-perm2': false,
'group2-perm1': false,
'group2-perm2': true,
'perm3': true,
'perm4': false,
})
.reduce((obj, entry) => {
const [key, checked] = entry;
const substrings = key.split('-');
const [group, perm] = substrings[1] ?
substrings : ['general', substrings[0]];
const list = obj[group] || []
return {...obj, [group]: list.concat({ value: key, checked, label: perm }) };
}, {});

qonf
Автор

Any reason why you chose to throw Ramda functions into global over destructuring the functions you needed?

MrPlaiedes
Автор

=> { value: p, checked: !!permissions[p], label: p.replace(/group[0-9]-/, '') });

So what was the need for Ramda here? Genuinely curious.

andreacappuccio