Skip to content

Instantly share code, notes, and snippets.

View viglioni's full-sized avatar
🤙

Laura Viglioni viglioni

🤙
View GitHub Profile

It is known that $\mathbb{Q}$ is a field. If we add $\sqrt{2}$ to the set

@viglioni
viglioni / string-bin.hs
Last active July 2, 2022 21:54
Encode/Decode strings into strings of binaries
--
-- Encodes/Decodes string in a string of binaries
--
-- Each char is converted to a string with eight 0s or 1s
-- λ> encode "The darkside of the force is a pathway to many abilities some consider to be unnatural"
-- "0101010001101000011001010010000001100100011000010111001001101011011100110110100101100100011001010
-- 01000000110111101100110001000000111010001101000011001010010000001100110011011110111001001100011011
-- 00101001000000110100101110011001000000110000100100000011100000110000101110100011010000111011101100
@viglioni
viglioni / non-empty-type.ts
Last active November 12, 2021 02:10
A NonEmpty<T> type for both objects and lists
// Typescript playground of this gist: https://www.typescriptlang.org/play?#code/PTAEBUE8AcFMGcCwAoFAXGtQDkD2A7AUQFtoMB5AIwCsAecAPlAF5QBvFUL7nrgbQDSoAJb5QAa1iRcAMwgBdAFygACsIDG4+gBpQAhp15cAvn0nS54eShvIMcHARJlIAQQBO7gIaR6TVnzgugB0oeB88vIA3Lb2WHhEpBh+LI6JLh7evoygAD5pzhQ0frYgoIQAHl6kADYIoLGYoADCBGhe6mipHMg8sMRewjXK8GjuogDm2oZc0AAWBLAjY5PTyMalwLg0oLjiKOoEo6BeoMoJhb6t+O2d-lxs84vKAERe8AAmLxvIh-jHlDOBSSVzaHTQ9zY-UGw1Ab0+3wORy66iBFxBtGutwh3Se+CWcPeX100KGryJiNQyBA22ooFgnlw7kUSP+XQ+aKcGKx4MhPz+xyw5y5LkxYLu3UoNS85IRPxQZRqwmOewav2RoDkwvSyXwAFdiJQGfc+KAAIygXQAJlA1nVbNAE05Ot8o3G+AmJrhZpelrhVt9doVYCVo1ODPcTJZ9uOc2dl1o+sNxtSprtAq6wnjGLdky9FvkQA
// My two references:
// for lists: https://stackoverflow.com/questions/56006111/is-it-possible-to-define-a-non-empty-array-type-in-typescript
// for objs: https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist
// Special thanks to @CaioCSdev https://github.com/CaioCSdev
/*
@viglioni
viglioni / resolvendo-problemas-com-fp.js
Created December 3, 2020 16:51
Código escrito durante o live coding "Resolvendo Problemas com Programação Funcional"
/*
* Links para o live coding:
* Parte I: https://www.youtube.com/watch?v=11HGQkaOT8c
* Parte II: https://www.youtube.com/watch?v=pFYIDtgkYb0
*/
/*
* Primeiro problema
*/
@viglioni
viglioni / introducao-ao-lisp.clj
Last active December 13, 2021 02:46
Código escrito durante o live coding "Introdução ao LISP"
;;
;; Link para o live coding: https://www.youtube.com/watch?v=IIp9YaXRHVY
;;
;;
;; Exemplo de map
;;
(map
(fn [x] (str "Hello " x))