All New

user:thomas gists created by user

title:mygist gists with given title

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

Register

Login


All New Register Login
's Avatar

gaiety

Joined 10 months ago

Recently created
Least recently created
Recently updated
Least recently updated
All gists 23
gaiety's Avatar

gaiety / toWords.hs

0 likes
0 forks
1 files
Last active 10 months ago
String To List Of Words
haskell
1 toWords :: String -> [String]
2 toWords x
3 | length x == 0 = []
4 | otherwise = takeWhile (/= ' ') x : toWords (drop 1 (dropWhile (/= ' ') x))
gaiety's Avatar

gaiety / Dynamic Length Arrays in JavaScript

0 likes
0 forks
1 files
Last active 10 months ago
array
1 let arrayOf100Things = [...Array(100).keys()];
gaiety's Avatar

gaiety / JS Map, easier than hash, reduces loops

0 likes
0 forks
1 files
Last active 10 months ago
Avoiding Nested Loops with `new Map()`
array loops map
1 let myHugeArray = [...Array(10000).keys()].map(id => { return {id}; });
2 let listIWant = [1010, 2020, 3030, 4040, 5050, 6060, 7070, 8080, 9090];
3
4 // INSTEAD OF:
5 myHugeArray.filter(obj => listIWant.includes(obj.id));
6
7 // TRY:
8 let mapIWant = new Map();
9 listIWant.forEach(id => mapIWant.set(id));
10 myHugeArray.filter(obj => mapIWant.has(obj.id));
Newer Older

Powered by Opengist ⋅ Load: 102ms⋅

English
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文
⋅ Links ⋅ Portfolio ⋅ Git