One Paragraph of project description goes here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
# This gist shows two different implementation of a Flatten function in Ruby. | |
# The workaround is to do something like the Deep-First Search algorithm to 'visit' all items contained in recursive arrays. | |
# These items are being added to the returning array after visited. | |
# First implementation: Recursive. | |
# The function tests if the object passed as argument is an array. | |
# If it does, it iterates it recursively, otherwise it adds the element to the visited elements array (acc). | |
def recursive_flatten(obj, acc = []) | |
obj.is_a?(Array) ? obj.each { |i| recursive_flatten(i, acc) } : acc << obj | |
acc |
Here you are the basics to create a Ruby Gem, with some appendix about interesting use cases. This guide tries to cover the minimum requirements to create a Gem using Ruby conventions. For more information, navigate to this link to see what is a Gem.
Most of Ruby Gems have lack of documentation, usage guides and examples. In order to make the usage comfortable would be important to have a robust guide.
object MergeSort { | |
// recursive merge of 2 sorted lists | |
def merge(left: List[Int], right: List[Int]): List[Int] = | |
(left, right) match { | |
case(left, Nil) => left | |
case(Nil, right) => right | |
case(leftHead :: leftTail, rightHead :: rightTail) => | |
if (leftHead < rightHead) leftHead::merge(leftTail, right) | |
else rightHead :: merge(left, rightTail) |
At DICOM Grid, we recently made the decision to use Haskell for some of our newer projects, mostly small, independent web services. This isn't the first time I've had the opportunity to use Haskell at work - I had previously used Haskell to write tools to automate some processes like generation of documentation for TypeScript code - but this is the first time we will be deploying Haskell code into production.
Over the past few months, I have been working on two Haskell services:
I will write here mostly about the first project, since it is a self-contained project which provides a good example of the power of Haskell. Moreover, the proces