This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package com.digitaslbi.helios.util; | |
| import java.time.LocalDate; | |
| import java.time.LocalDateTime; | |
| import java.time.ZoneOffset; | |
| import java.time.ZonedDateTime; | |
| import java.util.Date; | |
| import java.util.TimeZone; | |
| import org.junit.Test; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public static Map<String, String> convert(String[] s1, String[] s2) { | |
| return Option.when(ArrayUtils.isSameLength(s1, s2), () -> s1.length) | |
| .map(length -> Stream.range(0, length) | |
| .toMap(index -> Tuple.of(s1[index], s2[index]))) | |
| .getOrElse(HashMap.empty()); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | -module(palin_server). | |
| -export([server/1]). | |
| -import(palin, [palindrome/1]). | |
| server(From) -> | |
| receive | |
| {check,Msg} -> | |
| case palindrome(Msg) of | |
| true -> From ! {result, Msg ++ " is a palindrome"}; | |
| false -> From ! {invalid, "stopped"} | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | -module(frequency_client). | |
| -export([main/0]). | |
| main() -> | |
| PiD = spawn(frequency, init, []), | |
| register(frequency, PiD). | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | %% Based on code from | |
| %% Erlang Programming | |
| %% Francecso Cesarini and Simon Thompson | |
| %% O'Reilly, 2008 | |
| %% http://oreilly.com/catalog/9780596518189/ | |
| %% http://www.erlangprogramming.org/ | |
| %% (c) Francesco Cesarini and Simon Thompson | |
| -module(frequency). | |
| -export([start/0,allocate/0,deallocate/1,stop/0]). | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import java.util.concurrent.{Callable, ExecutorService, Future, TimeUnit} | |
| import scala.util.Try | |
| object ParallelModule { | |
| type Par[A] = ExecutorService => Future[A] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | type PivotEquilibriumIndexes = List[Int] | |
| def calculatePivot(lst: List[Int]) : PivotEquilibriumIndexes = { | |
| lazy val sumLst = lst.tail.sum | |
| def isAnEquilibrium(leftSum: Int, rightSum: Int) : Boolean = leftSum == rightSum | |
| def iter(index: Int, leftList: Vector[Int], rightList: List[Int], leftSum: Int, rightSum: Int) : PivotEquilibriumIndexes = { | |
| rightList match { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | trait Tree[+A] | |
| case class Leaf[A](value: A, left: Tree[A], right: Tree[A]) extends Tree[A] | |
| case object Empty extends Tree[Nothing] | |
| type Distance[Node] = Map[Node, Int] | |
| type Distances[Node] = Map[Node, Distance[Node]] | |
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /** | |
| * EXERCISE | |
| * | |
| * Using `ZManaged.foreachPar` and other functions as necessary, implement a function | |
| * to read the contents of all files in parallel, but ensuring that if anything | |
| * goes wrong during parallel reading, all files are safely closed. | |
| */ | |
| def readFiles( | |
| files: List[String] | |
| ): ZIO[Blocking with Console, IOException, Unit] = | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import * as stout from 'readline-sync' | |
| import { pipe, flow } from 'fp-ts/lib/function' | |
| type Unit = any | |
| const unit: void = undefined | |
| type Console<A> = Return<A> | PrintLine<A> | ReadLine<A> | |
| class Return<A> { | |
| readonly _tag: "Return" = "Return" |