instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
// Trait.scala package example import quoted._ trait Trait { implicit val foo: Int = 23 } object Trait { inline def get: Trait = ${ getImpl } def getImpl(using Quotes): Expr[Trait] = '{ new Trait {} } }
Explain and rewrite the following Scala code:
package dundertext.editor import org.junit.Test import org.junit.Assert._ class SpanNodeTest { @Test def should_trim_left(): Unit = { // given val n = new SpanNode() n.text = " Hej " // when n.trimLeft() // then assertEquals("Hej ", n.text) } @Test def should_trim_right()...
Explain and rewrite the following Scala code:
package com.rumblesan.scalaexperiments.extend case class UserInfo(name: String, email: String) case class PaidUser(id: Long, name: String, email: String, payments: Double) object PaidUser { class PaidUserExtended(user: PaidUser) { def userInfo: UserInfo = UserInfo(user.name, user.email) } implicit def ...
Explain and rewrite the following Scala code:
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may...
Explain and rewrite the following Scala code:
package chapter.four import collection.JavaConversions._ import collection.mutable.Map object ExerciseSeven extends App { def printProperties(): Unit = { val properties: Map[String, String] = System.getProperties val maxLength = properties.keySet.maxBy(_.length).length val format = s"%-${maxLength}s\\...
Explain and rewrite the following Scala code:
/** * Copyright (C) 2009-2017 Lightbend Inc. <http://www.lightbend.com> */ package akka.japi.pf import FI.{ UnitApply, Apply, Predicate } private[pf] object CaseStatement { def empty[F, T](): PartialFunction[F, T] = PartialFunction.empty } private[pf] class CaseStatement[-F, +P, T](predicate: Predicate, apply: ...
Explain and rewrite the following Scala code:
package dielectric.syntax import org.apache.spark.Partitioner import org.apache.spark.rdd.RDD import org.apache.spark.rdd.RDD.rddToPairRDDFunctions import scala.reflect.ClassTag import scalaz.Applicative import spire.algebra.{ Monoid, Semigroup } trait RDDSyntax { implicit def rddSyntax[A](rdd: RDD[A]): RDDOps[A...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
Explain and rewrite the following Scala code:
package com.lunatic.mlx.kddcup99.mllib.metadata import org.apache.spark.rdd.RDD import org.apache.spark.sql.Row import org.apache.spark.sql.types._ /** * This is an evolution of the Prediction class, which contains the results of the anomaly detection analysis, * for each threshold strategy chosen. */ case clas...
Explain and rewrite the following Scala code:
package spark.examples import scala.math.random import spark._ import SparkContext._ object SparkPi { def main(args: Array[String]) { if (args.length == 0) { System.err.println("Usage: SparkPi <master> [<slices>]") System.exit(1) } val spark = new SparkContext(args(0), "SparkPi", Syste...
Explain and rewrite the following Scala code:
package im.actor.server.names import akka.actor.ActorSystem import akka.http.scaladsl.util.FastFuture import com.github.ghik.silencer.silent import im.actor.server.db.DbExtension import im.actor.server.persist.UserRepo import im.actor.storage.SimpleStorage import slick.dbio._ import scala.concurrent.Future /** * St...
Explain and rewrite the following Scala code:
package org.greencheek.spray.cache.memcached.keyhashing import org.junit.Assert._ import org.junit.runner.RunWith import org.specs2.runner.JUnitRunner import org.scalatest.Spec import org.specs2.mutable.Specification /** * Created by dominictootell on 28/05/2014. */ @RunWith(classOf[JUnitRunner]) class JenkinsKeyHa...
Explain and rewrite the following Scala code:
/* Copyright 2013 Nest Labs Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
package com.sksamuel.elastic4s.http.update import com.sksamuel.elastic4s.FieldsMapper import com.sksamuel.elastic4s.http.ScriptBuilderFn import com.sksamuel.elastic4s.update.UpdateDefinition import org.elasticsearch.common.bytes.BytesArray import org.elasticsearch.common.xcontent.{XContentBuilder, XContentFactory, XCo...
Explain and rewrite the following Scala code:
package com.nulabinc.backlog.r2b.mapping.file /** * @author * uchida */ case class MappingFileContainer( user: UserMappingFile, status: StatusMappingFile, priority: PriorityMappingFile )
Explain and rewrite the following Scala code:
package exercices import models.devoxx.{DevoxxApi, Speaker, Talk} import support.HandsOnSuite import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future import scala.util.{Success, Try} class e04_types_fonctionnels extends HandsOnSuite { /** * On commence maintenant à avoir fait ...
Explain and rewrite the following Scala code:
package com.sprayed.chat import com.sprayed.chat.domain._ import akka.actor.Actor import spray.routing._ import spray.http._ import MediaTypes._ import shapeless._ import akka.event.Logging import spray.client.pipelining._ // we don't implement our route structure directly in the service actor because // we want to...
Explain and rewrite the following Scala code:
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may...
Explain and rewrite the following Scala code:
package ru.biocad.ig.common.structures.tree /** * Created with IntelliJ IDEA. * User: pavel * Date: 18.06.14 * Time: 11:42 */ object TreeUtils { def dump[T](tree : AbstractTree[T], converter : T => String = (e : T) => e.toString) : String = { if (tree.isLeaf) { s"${tree.value.fold("")(converter)}:${tr...
Explain and rewrite the following Scala code:
package org.typeclassopedia import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.must.Matchers import scala.language.implicitConversions import org.typeclassopedia.std.Monoids.{given _} import org.typeclassopedia.std.Options.{given _, _} import org.typeclassopedia.std.Lists.{given _, _} class Trave...
Explain and rewrite the following Scala code:
package colossus.protocols.redis import colossus.core.DataBuffer import akka.util.{ByteString, ByteStringBuilder} import UnifiedProtocol._ import UnifiedBuilder._ sealed trait Reply { def raw: DataBuffer } sealed abstract class MessageReply(message: String) extends Reply { def prefix: ByteString def raw = {...
Explain and rewrite the following Scala code:
package org.geoscript.geometry import com.vividsolutions.jts.geom.util.AffineTransformation class Transform(tx: AffineTransformation) { def apply[G <: Geometry](g: G): G = { val res = g.clone().asInstanceOf[G] res.apply(tx) res } def translate(dx: Double, dy: Double): Transform = new Transform(...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
Explain and rewrite the following Scala code:
/* * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
Explain and rewrite the following Scala code:
package com.twitter.finagle.liveness import com.twitter.conversions.DurationOps._ import com.twitter.finagle.Backoff.EqualJittered import com.twitter.finagle.service._ import com.twitter.finagle.stats.{InMemoryStatsReceiver, NullStatsReceiver} import com.twitter.finagle.util.Rng import com.twitter.finagle.{Backoff, _}...
Explain and rewrite the following Scala code:
package com.emotioncity.soriento.testmodels import javax.persistence.Id import com.emotioncity.soriento.annotations.EmbeddedSet import com.orientechnologies.orient.core.id.ORID /** * Created by stream on 23.09.15. */ case class ClassWithOptionalField(simpleField: Int, optField: Option[String]) case class ClassWith...
Explain and rewrite the following Scala code:
package $basePackageName$; case class Application(name: String)
Explain and rewrite the following Scala code:
package bills import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.duration.DurationInt import akka.actor.Actor import akka.actor.ActorRef import akka.actor.PoisonPill import akka.actor.Props import scala.language.postfixOps object SnakeConfig { val marchTimeSeconds = 1 } case class ...
Explain and rewrite the following Scala code:
package com.sageserpent.plutonium.javaApi import java.time.Instant import com.sageserpent.plutonium.ItemExtensionApi.UniqueItemSpecification import com.sageserpent.plutonium.{ typeTagForClass, Annihilation => ScalaAnnihilation } object Annihilation { def apply[Item](definiteWhen: Instant, id:...
Explain and rewrite the following Scala code:
package ch.epfl.telegram.commands import akka.http.scaladsl.util.FastFuture import ch.epfl.telegram.models.Reaction import com.lightbend.emoji.ShortCodes.Defaults._ import com.lightbend.emoji.ShortCodes.Implicits._ import info.mukel.telegrambot4s.Implicits._ import info.mukel.telegrambot4s.api.{Callbacks, Commands, Te...
Explain and rewrite the following Scala code:
/* * Copyright 2011 WorldWide Conferencing, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable l...
Explain and rewrite the following Scala code:
package org.nd4j.api.ops import org.nd4j.linalg.api.complex.IComplexNumber import org.nd4j.linalg.api.ndarray.INDArray import org.nd4j.linalg.api.ops.{BaseScalarOp, Op} import org.nd4j.linalg.factory.Nd4j import org.nd4j.api.Implicits._ object FilterOps{ def apply(x:INDArray,f:Double=>Boolean):FilterOps = new Filte...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2013 Alcatel-Lucent. * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. * Licensed to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a cop...
Explain and rewrite the following Scala code:
package com.betfair.domain import play.api.libs.json.{Writes, Reads} object ExecutionReportStatus extends Enumeration { type ExecutionReportStatus = Value val SUCCESS, FAILURE, PROCESSED_WITH_ERRORS, TIMEOUT = Value implicit val enumReads: Reads[ExecutionReportStatus] = EnumUtils.enumReads(ExecutionRepor...
Explain and rewrite the following Scala code:
package edu.gemini.catalog.image import scalaz.concurrent.Task /** A concurrent mutable cell for type A. */ sealed trait TaskRef[A] { /** Atomic modification. */ def mod(f: A => A): Task[Unit] /** Return the current value. */ def get: Task[A] /** Replace the current value. */ def put(a: A): Task[Unit] ...
Explain and rewrite the following Scala code:
package io.github.mandar2812.dynaml.pipes import org.scalatest.{FlatSpec, Matchers} import scala.collection.mutable.ArrayBuffer /** * Created by mandar on 13/7/16. */ class DataPipesSpec extends FlatSpec with Matchers { "A Data Pipe" should "have type consistency" in { val pipe = DataPipe((x: Int) => x+1)...
Explain and rewrite the following Scala code:
package scala.tools.nsc.scaladoc import java.io.StringWriter import org.scalacheck.Prop._ import org.scalacheck._ import scala.collection.mutable import scala.tools.nsc.doc.html.HtmlPage object HtmlFactoryTest extends Properties("HtmlFactory") { final val RESOURCES = "test/scaladoc/resources/" import scala.t...
Explain and rewrite the following Scala code:
package data import scala.collection.mutable.ListBuffer case class QuestionBook(categories: List[Category]) { def withoutLearnt(): QuestionBook = { val newCategories = List[Category]() for (cat <- categories) { val needToLearnQuestions = cat.questions.filter(_.learnt != Learnt.Yes) if (needToLea...
Explain and rewrite the following Scala code:
package org.apache.spark.sql.snowflake /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, V...
Explain and rewrite the following Scala code:
package controllers import javax.inject.Inject import play.api.mvc._ import scala.concurrent.{ExecutionContext, Future} import models.db /** * * @author ponkotuy * Date: 14/03/22. */ class RestSound @Inject()(val controllerComponents: ControllerComponents, implicit val ec: ExecutionContext) extends BaseControll...
Explain and rewrite the following Scala code:
package dk.gp.cogp.lb.grad import breeze.linalg.DenseMatrix import breeze.linalg.DenseVector import breeze.linalg.trace import dk.gp.cov.utils.covDiagD import breeze.numerics._ import breeze.linalg._ import dk.gp.cogp.lb.LowerBound import dk.gp.cogp.lb.wAm import dk.gp.math.diagProd object calcLBGradHypCovG { def ...
Explain and rewrite the following Scala code:
/** * Global Sensor Networks (GSN) Source Code * Copyright (c) 2006-2016, Ecole Polytechnique Federale de Lausanne (EPFL) * * This file is part of GSN. * * GSN is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation,...
Explain and rewrite the following Scala code:
package testfeature import feature._ import org.scalatest.FunSuite /** * Created by prussell on 11/12/16. */ class FeatureIntersectSuite extends FunSuite { test("Generic feature intersect generic feature") { assert(new GenericFeature(chr1_1500_1600_1700_1800_2100_2300_plus, Some("name")) .intersectio...
Explain and rewrite the following Scala code:
package io.muvr import akka.actor._ import com.typesafe.config.ConfigFactory import scala.collection.JavaConversions._ /** * CLI application for the exercise app */ object MuvrApp extends App with Muvr { lazy val config = { val role = "muvr-monolith" val clusterShardingConfig = ConfigFactory.parseString...
Explain and rewrite the following Scala code:
package org.bitcoins.node import akka.actor.ActorSystem import org.bitcoins.chain.config.ChainAppConfig import org.bitcoins.core.bloom.BloomFilter import org.bitcoins.core.protocol.BitcoinAddress import org.bitcoins.core.protocol.transaction.Transaction import org.bitcoins.node.config.NodeAppConfig import org.bitcoins...
Explain and rewrite the following Scala code:
package com.fpis.ch02 /** * EXERCISE 6: Implement the higher-order function that composes two * functions. */ object Ex6_Compose { def compose[A, B, C](f: B => C, g: A => B): A => C = { def fn_from_A_To_C: A => C = (a: A) => f(g(a)) // or // def fn(a: A): C = f(g(a)) fn_from_A_To_C } }
Explain and rewrite the following Scala code:
package cz.vzdusne.schist import org.jfree.chart._ import org.jfree.data.xy.DefaultXYDataset package object ui { def plot[T: Numeric](histogram: Histogram1D[T]) : Unit = { val dataset = new DefaultXYDataset val x = histogram.binEdges.toArray val y = histogram.asDouble.frequencies dataset.addSeries(...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2016-2019 Lightbend Inc. <https://www.lightbend.com> */ package com.lightbend.lagom.internal.logback import java.io.File import java.net.URL import org.slf4j.impl.StaticLoggerBinder import org.slf4j.{ ILoggerFactory, LoggerFactory } import play.api._ import scala.util.control.NonFatal object L...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
Explain and rewrite the following Scala code:
package xebia.r2d2 import java.sql.Connection import java.util.concurrent.Executors import akka.actor.{ ActorRef, ActorSystem, Status } import akka.testkit.{ ImplicitSender, TestActorRef, TestKit } import org.joda.time.DateTime import org.specs2.mock.Mockito import org.specs2.mutable.{ After, Specification } import ...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
import shapeless._ import shapeless.ops.hlist._ object LazyImp { implicit def dc(implicit a: C *** D): D *** C = ??? implicit def d(implicit a: D *** C): D = ??? implicit def c(implicit a: Lazy[D]): C = ??? implicitly[C] }
Explain and rewrite the following Scala code:
/* * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by ap...
Explain and rewrite the following Scala code:
package modules import com.google.inject.{ AbstractModule, Provides } import com.mohiva.play.silhouette.api.repositories.AuthInfoRepository import com.mohiva.play.silhouette.api.services._ import com.mohiva.play.silhouette.api.util._ import com.mohiva.play.silhouette.api.{ Environment, EventBus } import com.mohiva.pla...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
package com.ibm.finance.cfpb.cc.driver import java.sql.Timestamp /** * Created by arunwagle on 8/17/16. */ case class ConsumerComplaintsFiltered (complaint_id: String, received_date : Timestamp , issue: String, product: String, state: String ...
Explain and rewrite the following Scala code:
/* * Copyright 2014 Databricks * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
Explain and rewrite the following Scala code:
import sbt._ import sbt.Keys._ import com.typesafe.sbt.pgp.PgpKeys._ object Common { def version = "3.0.4" } object BuildSettings { val publishSettings = Seq( version := Common.version, organization := "au.com.dius", scalaVersion := "2.10.5", publishMavenStyle := true, ...
Explain and rewrite the following Scala code:
/* * Copyright 2016 The BigDL Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agr...
Explain and rewrite the following Scala code:
package hu.arnoldfarkas.rushhour.rushhour object RushHourState { def isFinal(state: RushHourState, car: Car): Boolean = state.cars.contains(car) } case class RushHourState(val cars: Set[Car])(implicit val field: Field) { override def toString: String = "State: "+ cars.toString() override def equals(obj: s...
Explain and rewrite the following Scala code:
import java.io._ import scala.reflect.runtime.universe._ class Reader(fname: String) { private val in = new BufferedReader(new FileReader(fname)) @throws[IOException]("if the file doesn't exist") def read() = in.read() } object Test extends dotty.runtime.LegacyApp { def test(sym: MethodSymbol): Unit = { p...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014-2021 by The Monix Project Developers. * See the project homepage at: https://monix.io * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache...
Explain and rewrite the following Scala code:
/* * Copyright 2014-2021 Netflix, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agr...
Explain and rewrite the following Scala code:
/* * Copyright 2020 Daniel Spiewak * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed ...
Explain and rewrite the following Scala code:
import scala.util.Properties /** * Load environment variables into SBT (could be versions or any other values) */ object Environment { def either(environmentVariable: String, default: String): String = Properties.envOrElse(environmentVariable, default) lazy val hadoopVersion = either("SPARK_HADOOP_VERSIO...
Explain and rewrite the following Scala code:
/* * Copyright 2016 The BigDL Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agr...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
object Foo { private def f {} } class Foo { println(Foo./* line: 2 */f) } class Bar { println(Foo./* line: 2, accessible: false */f) }
Explain and rewrite the following Scala code:
/* * Copyright 2015 Netflix, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed t...
Explain and rewrite the following Scala code:
/* * Copyright 2014 Treode, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to...
Explain and rewrite the following Scala code:
package org.scalatra.ssgi import java.util.Locale sealed trait HttpMethod { val isSafe: Boolean } case object Options extends HttpMethod { val isSafe = true override def toString = "OPTIONS" } case object Get extends HttpMethod { val isSafe = true override def toString = "GET" } case object Head extends Htt...
Explain and rewrite the following Scala code:
package mesosphere.marathon package core.pod import mesosphere.marathon.plugin.ContainerSpec import mesosphere.marathon.raml.{Artifact, Endpoint, Image, Lifecycle, MesosExec, Resources} import mesosphere.marathon.state.{LinuxInfo, VolumeMount} import scala.collection.immutable.Map case class MesosContainer( name...
Explain and rewrite the following Scala code:
package org.openurp.edu.eams.web.action.common abstract class SemesterSupportAction extends ProjectSupportAction { def index(): String = { setSemesterDataRealm(hasStdTypeCollege) indexSetting() forward() } def setSemesterDataRealm(realmScope: Int) { setDataRealm(realmScope) putSemester(g...
Explain and rewrite the following Scala code:
package com.twitter.scalding import com.twitter.scalding.serialization._ import org.specs._ import java.io.{ByteArrayOutputStream=>BOS} import java.io.{ByteArrayInputStream=>BIS} import scala.collection.immutable.ListMap import scala.collection.immutable.HashMap import com.twitter.algebird.{AveragedValue, DecayedV...
Explain and rewrite the following Scala code:
package ecommerce.shipping.app import akka.kernel.Bootable import com.typesafe.config.Config import ecommerce.shipping.{HttpService, ShippingReadFrontConfiguration} class ShippingReadFrontApp extends Bootable { override def systemName = "shipping-read-front" def startup() = { new ShippingReadFrontConfigura...
Explain and rewrite the following Scala code:
/** * Licensed to the Minutemen Group under one or more contributor license * agreements. See the COPYRIGHT file distributed with this work for * additional information regarding copyright ownership. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in complian...
Explain and rewrite the following Scala code:
/*** * Excerpted from "Seven Concurrency Models in Seven Weeks", * published by The Pragmatic Bookshelf. * Copyrights apply to this code. It may not be used to create training material, * courses, books, articles, and the like. Contact us if you are in doubt. * We make no guarantees that this code is fit for any ...
Explain and rewrite the following Scala code:
package com.sksamuel.elastic4s.indexes class IndexSettings { private val ShardsKey = "number_of_shards" private val ReplicasKey = "number_of_replicas" private val RefreshIntervalKey = "refresh_interval" val settings = scala.collection.mutable.Map.empty[String, Any] def shards: Option[Int] ...
Explain and rewrite the following Scala code:
package com.appliedscala.generator.services import com.appliedscala.generator.errors.InitError import org.slf4j.LoggerFactory import zio.IO import java.io.{File, PrintWriter} import java.nio.file.{Files, Paths} import scala.io.Source class InitService { private val logger = LoggerFactory.getLogger(this.getClass) ...
Explain and rewrite the following Scala code:
/* * Copyright 2016 The BigDL Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agr...
Explain and rewrite the following Scala code:
package lang.lightweightjava import org.scalatest.{FlatSpec, Matchers} class TypeCheckerTest extends FlatSpec with Matchers { val p1 = "class X {\\n" + " X field;\\n" + " X m2(X var1, X var2) {\\n" + " if (var1 == var2)\\n" + " var1 = new Y();\\n" + " else {\\n"...
Explain and rewrite the following Scala code:
/* * Copyright 2012-2014 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unl...
Explain and rewrite the following Scala code:
package is.hail.expr.ir import is.hail.{ExecStrategy, HailSuite} import is.hail.TestUtils.assertEvalsTo import is.hail.expr.ir.TestUtils.IRAggCount import is.hail.types.virtual._ import is.hail.utils.{FastIndexedSeq, FastSeq, Interval} import is.hail.variant.Locus import org.apache.spark.sql.Row import org.testng.anno...
Explain and rewrite the following Scala code:
package skinny.assets import org.scalatest._ class LessCompilerSpec extends FlatSpec with Matchers { behavior of "LessCompiler" it should "compile code" in { val compiler = LessCompiler val css = compiler.compile( "box.less", """@base: #f938ab; | |.box-shadow(@style, @c) when...
Explain and rewrite the following Scala code:
class A { case class B(s: String) } object X { def foo: Unit = { val b = a.B.toString val a = new A } }
Explain and rewrite the following Scala code:
@main def happyBirthday(age: Int, name: String, others: String*) = { val suffix = (age % 100) match { case 11 | 12 | 13 => "th" case _ => (age % 10) match { case 1 => "st" case 2 => "nd" case 3 => "rd" case _ => "th" } } val bldr = new Stri...
Explain and rewrite the following Scala code:
/* * Copyright (C) Lightbend Inc. <https://www.lightbend.com> */ package docs.scaladsl.mb import com.lightbend.lagom.scaladsl.api.ServiceCall import com.lightbend.lagom.scaladsl.persistence.EventStreamElement import com.lightbend.lagom.scaladsl.persistence.PersistentEntityRegistry import com.lightbend.lagom.scalads...
Explain and rewrite the following Scala code:
import org.specs2.mutable._ import org.scoverage.issue53.part.b.SubtractorScala /** * Created by Mikhail Kokho on 7/10/2015. */ class SubtractorTestSuite extends Specification { "Subtractor" should { "subtract two numbers" in { SubtractorScala.minus(2, 1) mustEqual 1 } } }
Explain and rewrite the following Scala code:
package com.ubeeko.htalk.tests import org.scalatest._ import com.ubeeko.htalk.criteria._ import org.apache.hadoop.hbase.util.Bytes import org.apache.hadoop.hbase.CellUtil import org.apache.hadoop.hbase.filter.FilterList import java.util.HashMap import java.util.ArrayList class HBaseEngineSpec extends FlatSpec...
Explain and rewrite the following Scala code:
package io.vamp.common.akka import java.util.concurrent.atomic.AtomicInteger import _root_.akka.pattern.ask import akka.actor._ import akka.util.Timeout import com.typesafe.scalalogging.LazyLogging import io.vamp.common.Namespace import io.vamp.common.util.TextUtil import scala.collection.mutable import scala.concur...
Explain and rewrite the following Scala code:
package org.bitcoins.rpc.bitcoincore.blockchain.softforks /** * Created by Tom on 1/11/2016. */ trait RejectionProgress { def status : Boolean def newVersionBlocksFound : Int def requiredBlocks : Int def recentBlocksWindow : Int } case class RejectionProgressImpl(status : Boolean , newVersionBlocksFound : I...
Explain and rewrite the following Scala code:
object Solution { def main(args: Array[String]): Unit = { val n = scala.io.StdIn.readInt var i = 0 var result = 0 for (i <- 1 to 10) { def result = n * i var resultMessage = "{N} x {I} = {RESULT}" resultMessage = "\\\\{N\\\\}".r.replaceAllIn(r...
Explain and rewrite the following Scala code:
/* * Copyright 2016 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
Explain and rewrite the following Scala code:
package com.goticks import org.scalatest.{WordSpecLike, MustMatchers} import akka.testkit.{ImplicitSender, TestKit} import akka.actor.{Props, ActorSystem} // ********** ********** ********** ********** ********** ********** ********** \\\\ class TicketSellerSpec extends TestKit(ActorSystem("testTickets")) with WordSpe...
Explain and rewrite the following Scala code:
package ml.wolfe import gnu.trove.map.hash.{TObjectIntHashMap, THashMap} import scala.collection import gnu.trove.procedure.{TObjectObjectProcedure, TObjectIntProcedure} /** * @author Sebastian Riedel */ class HierarchicalIndex extends Index { private var _size = 0 def size = _size def key(index: Int) = ??...
Explain and rewrite the following Scala code:
package coverage.sample class Class2 { def msg_test = println("test code") }
Explain and rewrite the following Scala code:
/* * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
Explain and rewrite the following Scala code:
/*********************************************************************** * Copyright (c) 2013-2020 Commonwealth Computer Research, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Apache License, Version 2.0 * which accompanies this distribution and...
Explain and rewrite the following Scala code:
package com.sksamuel.elastic4s.alias case class IndicesAliasesRequestDefinition(actions: Seq[AliasActionDefinition]) trait AliasActionDefinition