Skip to content

Instantly share code, notes, and snippets.

@lipemorais
lipemorais / question1.py
Created September 8, 2023 19:11
Question 1 - IBM test hacker rank
def primeira_parte(quantity, last_index):
lista = quantity[:last_index]
# print(lista)
return sum(lista)
def segunda_parte(quantity, first_index):
lista = quantity[first_index:]
myLast :: Eq a => [a] -> a
myLast (x:xs)
| xs == [] = x
| otherwise = myLast xs
myLast' :: Eq a => [a] -> a
myLast' (x:y:xs)
| xs == [] = x
| otherwise = myLast' (y:xs)
'.source.python':
'model':
'prefix': 'sam'
'body': """
class ${1:MODELNAME}(db.Model):
__tablename__ = "${2:TABLENAME}"
${3:FIELDNAMES}
def __init__(self):
${4:# TODO add initializer fields}
import Prelude hiding (elem, map)
elem :: Eq a => a -> [a] -> Bool
elem _ [] = False
elem x (y:ys)
| x == y = True
| otherwise = elem x ys
factorial :: Int -> Int
factorial 1 = 1
@lipemorais
lipemorais / presentation.hs
Created February 18, 2016 14:31
Programação Funcional no Haskell
import Prelude hiding (elem, map)
elem :: Eq a => a -> [a] -> Bool
elem _ [] = False
elem x (y:ys)
| x == y = True
| otherwise = elem x ys
factorial :: Int -> Int
factorial 1 = 1