Skip to content

Instantly share code, notes, and snippets.

View ceolinrenato's full-sized avatar

Renato Ceolin ceolinrenato

View GitHub Profile
@ceolinrenato
ceolinrenato / n_grams.exs
Last active April 28, 2021 19:18
n_grams.exs
# Renato Ceolin - 10/28/2020
# Built with elixir 1.11
# To run the code use the comamnd `elixir n_grams.exs`
# Tests will be run after the script execution
defmodule NGrams do
@moduledoc """
NGrams are continguos sequences of words in a sentence
"""
@ceolinrenato
ceolinrenato / flatten_array.rb
Last active September 23, 2020 17:07
Recursive flatten array
# frozen_string_literal: true
def flatten_array(array)
raise ArgumentError unless array.class == Array
flattened = []
array.each do |item|
if item.class == Array
flattened += flatten_array(item)
else