Scala : List data structure element removal

Objective –   Implement the function tail for removing the first element of a List. Solution –  object patternmatcing extends App { sealed trait List[+A] // deifine trait list with sealed i.e all functions ust be declared here case object Nil extends List[Nothing] // case object case class Cons[+A](head: A, tail: List[A]) extends List[A] // case… Read More Scala : List data structure element removal

Scala : Check Sort using anonymous function

object issorted extends App{ def issorted[A](as:Array[A],ordered:(A,A)=>Boolean):Boolean= { def loop(n:Int): Boolean = { if (n<=0) true // if recursion goes to first element then array is sorted else ordered(as(n),as(n-1)) && loop(n-1) // else check the and && conditions for oredred function and loop(n-1) .. bith true then true else false } loop(as.length-1) } print(issorted(Array(1,2,3,4,5),(x:Int,y:Int)=>x>y)) // declare… Read More Scala : Check Sort using anonymous function

Apache spark:- Maximum temperature in a file using scala

HI, in this blog I will explain how to find the maximum temperature in a text file     We need to configure eclipse with spark first which is already described in earlier blog     Sample input:- 91    67    Agra  Uttar Pradesh     33    19 90    67    Allahabad   Uttar Pradesh     32    19 87    60    Amritsar   … Read More Apache spark:- Maximum temperature in a file using scala