instruction
stringclasses
1 value
output
stringlengths
5
1M
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 org.salgo.sequences.shuffling import scala.reflect.ClassTag import scala.util.Random object FisherYates { def shuffle[T <: Any : ClassTag](seq: Seq[T]) : Seq[T] = { val result = seq.toArray val random = new Random() for (i <- 0 to seq.length - 1) { val rdm = random.nextInt(i + 1) val...
Explain and rewrite the following Scala code:
package com.opentok.udfs import com.typesafe.scalalogging.Logger import org.apache.hadoop.hive.ql.exec.Description import org.apache.hadoop.hive.ql.udf.generic.GenericUDF import org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector...
Explain and rewrite the following Scala code:
package net.kwas.impatient.ch6 import org.scalatest._ class PointSpec extends FlatSpec with Matchers { "A Point" should "be constructable from the companion object" in { val point = Point(1, 2) point.x should be (1) point.y should be (2) } }
Explain and rewrite the following Scala code:
package im.actor.server.bot.services import akka.actor.ActorSystem import im.actor.bots.BotMessages._ import im.actor.concurrent.FutureResult import im.actor.server.acl.ACLUtils import im.actor.server.bot.{ ApiToBotConversions, BotServiceBase } import im.actor.server.db.DbExtension import im.actor.server.file.{ FileSt...
Explain and rewrite the following Scala code:
package Tutorial import Chisel._ import Node._ import Literal._ import scala.collection.mutable.HashMap import scala.collection.mutable.ArrayBuffer class updateWriter (extCompName:String) extends gComponentLeaf (() => new update_t)(() => new prDone_t) (ArrayBuffer(("mem", () => new mem_req_t , () => new mem_rep_t),...
Explain and rewrite the following Scala code:
package edu.cornell.cdm89.scalaspec.pde import edu.cornell.cdm89.scalaspec.ode.PointVec object LaxFriedrichsFlux { case class BoundaryValues(t: Double, u: PointVec, flux: PointVec, maxLambda: Double, norm: Double) case class NumericalFlux(t: Double, fStar: PointVec) def flux(bv1: BoundaryValues, bv2: B...
Explain and rewrite the following Scala code:
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** @author Michael E. Cotterell & Alec Molinaro * @version 1.2 * @date THR Apr 20 00:05:16 EST 2015 * @see LICENSE (MIT style license file). */ package scalation.plot import javafx.application.Application import javaf...
Explain and rewrite the following Scala code:
package com.github.gdefacci.briscola package competition import player._ final case class CompetitionId(id:Long) final case class Competition(players:GamePlayers, kind:MatchKind, deadline:CompetitionStartDeadline/*, FIXME"this functionality needs a timer" endTime:LocalDateTime */) sealed trait MatchKind case object...
Explain and rewrite the following Scala code:
/** * COPYRIGHT (C) 2015 Alpine Data Labs Inc. All Rights Reserved. */ package com.alpine.plugin.core.spark.utils import org.apache.spark.mllib.linalg.DenseVector import org.apache.spark.mllib.regression.LabeledPoint import org.apache.spark.sql.Row /** * Helper functions that are useful for working with MLlib. */...
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 Vals { val List() = List() val List() = List() val List() = List() lazy val List() = List() val x1a = List(1) val x1b: List[Int] = List(1) var x2a = List(2) var x2b: List[Int] = List(2) implicit val x3a = List(3) implicit val x3b: List[Int] = List(3) implicit lazy val x4a = List(4) implic...
Explain and rewrite the following Scala code:
package edu.emory.mathcs.ir.liveqa.parsing import com.typesafe.scalalogging.LazyLogging import edu.emory.mathcs.ir.liveqa.base.AnswerCandidate._ import edu.emory.mathcs.ir.liveqa.base.{AnswerCandidate, Question} import org.joda.time.DateTime import scala.collection.mutable import scala.io.Source import scala.util.Ran...
Explain and rewrite the following Scala code:
/* * Copyright 2020 Frugal Mechanic (http://frugalmechanic.com) * * 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...
Explain and rewrite the following Scala code:
package ecommerce.shipping.app import akka.actor._ import akka.kernel.Bootable import com.typesafe.config.ConfigFactory import ecommerce.shipping.ShippingViewUpdateService import scala.slick.driver.{JdbcProfile, PostgresDriver} class ShippingViewUpdateApp extends Bootable { private val config = ConfigFactory.load(...
Explain and rewrite the following Scala code:
/* * Copyright 2012 OneCalendar * * 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 w...
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 amora.frontend import scala.scalajs.js package object webui extends JsUtils { implicit class AsDynamic[A](private val a: A) extends AnyVal { def jsg: js.Dynamic = a.asInstanceOf[js.Dynamic] } }
Explain and rewrite the following Scala code:
package io.finch import java.nio.charset.Charset import cats.Show import com.twitter.io.Buf /** * Encodes an HTTP payload (represented as an arbitrary type `A`) with a given [[Charset]]. */ trait Encode[A] { type ContentType <: String def apply(a: A, cs: Charset): Buf } trait LowPriorityEncodeInstances { ...
Explain and rewrite the following Scala code:
/******************************************************************************* * Copyright (c) 2019. Carl Minden * * This program 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, either version 3 of the ...
Explain and rewrite the following Scala code:
package dotty.tools.dotc package transform import core._ import MegaPhase._ import Contexts.Context import Flags._ import SymUtils._ import Symbols._ import SymDenotations._ import Types._ import Decorators._ import DenotTransformers._ import StdNames._ import NameKinds._ import ast.Trees._ import collection.mutable ...
Explain and rewrite the following Scala code:
package it import java.io.File import java.util.concurrent.{CountDownLatch, TimeUnit} import java.util.concurrent.atomic.LongAdder import com.bwsw.commitlog.filesystem.CommitLogCatalogue import com.bwsw.tstreamstransactionserver.netty.client.Client import com.bwsw.tstreamstransactionserver.netty.server.{Server, Time}...
Explain and rewrite the following Scala code:
package com.holdenkarau.spark.testing import java.sql.{Date, Timestamp} import org.apache.spark.sql.types._ import org.apache.spark.sql.{DataFrame, Row, SQLContext} import org.scalacheck.{Arbitrary, Gen} object DataframeGenerator { /** * Creates a DataFrame Generator for the given Schema. * * @param sqlC...
Explain and rewrite the following Scala code:
/** * This file is part of the TA Buddy project. * Copyright (c) 2013-2014 Alexey Aksenov ezh@ezh.msk.ru * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Affero General Global License version 3 * as published by the Free Software Foundation with the addition...
Explain and rewrite the following Scala code:
/** * Copyright 2013 Zhan Shi * * 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...
Explain and rewrite the following Scala code:
/* * Copyright 2022 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.inject.conversions import com.twitter.util.{Future, Return, Throw, Try} object option { /* ---------------------------------- */ object RichOption { //In companion so can be called from httpfuture.scala def toFutureOrFail[A](option: Option[A], throwable: => Throwable) = { optio...
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:
/* * 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 me.yingrui.segment.tools.ner import me.yingrui.segment.tools.CorpusLoader.convertToSegmentResult import me.yingrui.segment.tools.accurary.SegmentResultComparator import org.junit.{Assert, Test} class PRFCorpusToSerialLabelCompareHookerTest { @Test def should_label_chinese_family_name_as_b() { val exp...
Explain and rewrite the following Scala code:
/* ************************************************************************************* * Copyright 2011 Normation SAS ************************************************************************************* * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero Ge...
Explain and rewrite the following Scala code:
package example import scala.language/*->scalaShadowing::language.*/.higherKinds/*->scalaShadowing::language.higherKinds.*/ class Anonymous/*<-example::Anonymous#*/ { this: Anonymous/*->example::Anonymous#*/ => def locally/*<-example::Anonymous#locally().*/[A/*<-example::Anonymous#locally().[A]*/](x/*<-example::A...
Explain and rewrite the following Scala code:
package controllers import java.util.concurrent.ThreadLocalRandom import scala.concurrent.{Future, ExecutionContext} import play.api.libs.json.{JsObject, Json, JsValue} import play.api.mvc._ import play.mvc.Http import reactivemongo.api.ReadPreference import reactivemongo.play.json.collection.JSONCollection import p...
Explain and rewrite the following Scala code:
//////////////////////////////////////////////////////////////////////////////// // // // OpenSolid is a generic library for the representation and manipulation // // of geometric objects such as points, curves, surfaces, and volumes. ...
Explain and rewrite the following Scala code:
package com.eevolution.context.dictionary.domain.api.repository import com.eevolution.context.dictionary._ /** * Copyright (C) 2003-2017, e-Evolution Consultants S.A. , http://www.e-evolution.com * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Publi...
Explain and rewrite the following Scala code:
package gitbucket.core.service import gitbucket.core.model.{Issue, PullRequest, CommitStatus, CommitState, CommitComment} import gitbucket.core.model.Profile._ import gitbucket.core.model.Profile.profile.blockingApi._ import difflib.{Delta, DiffUtils} import gitbucket.core.util.SyntaxSugars._ import gitbucket.core.uti...
Explain and rewrite the following Scala code:
package com.tpl.lib.gui.config import com.tpl.lib.gui.WidgetPlayerInventory import net.bdew.lib.gui.{Point, Color} class PlayerInventoryContainerInfo(val x: Int, val y: Int, val hotbarY: Int) {} trait PlayerInventoryLoading { val widgets: Map[String, Any] val textures: TextureGuiConfig def getPlayerInventoryW...
Explain and rewrite the following Scala code:
package com.arcusys.valamis.web.servlet.content.response import org.json4s.JsonAST.{JNothing, JValue} import org.json4s.jackson.JsonMethods._ import org.json4s.{CustomSerializer, DefaultFormats, Extraction} /** * User: Yulia.Glushonkova * Date: 05.05.14 */ case class AnswerResponse( answerId: Long = 0, answerT...
Explain and rewrite the following Scala code:
package types import types.Types._ import scala.language.{postfixOps, implicitConversions} case class Sequent(left: Set[Prop], right: Set[Prop]) { /** * Indica si el secuente es un Axioma * @return */ def isAxiom = left.exists(right.contains) /** * Calcula el secuente obtenido de aplicar al ...
Explain and rewrite the following Scala code:
/* * Copyright 2014 http4s.org * * 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:
package lila.round import scala.concurrent.duration._ import scala.concurrent.Promise import akka.actor._ import akka.pattern.{ ask, pipe } import chess.Color import chess.format.Uci import play.api.libs.json.{ JsObject, Json } import actorApi._, round._ import lila.common.PimpedJson._ import lila.game.{ Game, Pov, ...
Explain and rewrite the following Scala code:
/*!md --- layout: tutorial title: The Hello World Program topic: reactors logoname: reactress-mini-logo-flat.png projectname: Reactors.IO homepage: http://reactors.io permalink: /reactors/hello-world/index.html pagenum: 3 pagetot: 40 section: guide-intro --- !*/ package tutorial import org.scalatest._ import scala.c...
Explain and rewrite the following Scala code:
/* * Copyright 2017 Exon IT * * 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 w...
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.github.mdr.graphospasm.grapheditor.model.commands import com.github.mdr.graphospasm.grapheditor.model._ import com.github.mdr.graphospasm.core.graph._ import org.eclipse.gef.commands.Command import org.eclipse.draw2d.geometry.Rectangle import org.eclipse.gef.commands.Command; class SetEdgeLabelCommand(val...
Explain and rewrite the following Scala code:
/* ### Module API bundle This bundle describes generic API for Bio4j modules */ package ohnosequences.bio4j.statika import shapeless._ import ohnosequences.typesets._ import ohnosequences.statika._ /* Abstract interface: */ trait AnyAPIBundle extends AnyBundle /* Constructor: */ abstract class APIBundle[ D <: Ty...
Explain and rewrite the following Scala code:
package uk.co.pragmasoft.graphdb import com.tinkerpop.blueprints.{TransactionalGraph, Vertex} import uk.co.pragmasoft.graphdb.marshalling.{GraphMarshallingDSL, GraphMarshaller} import uk.co.pragmasoft.graphdb.validation.GraphDAOValidations trait GraphDAO[T] extends CrudDAO[T] with GraphMarshallingDSL { self: Graph...
Explain and rewrite the following Scala code:
package com.sksamuel.elastic4s.analysis import com.sksamuel.elastic4s.json.{XContentBuilder, XContentFactory} import com.sksamuel.exts.OptionImplicits._ trait TokenFilter { def name: String def build: XContentBuilder } case class SynonymTokenFilter(override val name: String, path: O...
Explain and rewrite the following Scala code:
/** * Copyright (C) 2009-2011 the original author or authors. * See the notice.md 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 compliance with the License. * Yo...
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:
/* * 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 sbt.Keys._ import sbt._ import org.scalastyle.sbt.ScalastylePlugin object TestSettings { private[this] lazy val checkScalastyle = taskKey[Unit]("checkScalastyle") def testSettings: Seq[Def.Setting[_]] = Seq( fork in Test := true, // Run Scalastyle as a part of tests checkScalastyle := Scalas...
Explain and rewrite the following Scala code:
package com.twitter.finagle.benchmark import com.twitter.finagle.Service import com.twitter.finagle.tracing._ import com.twitter.util.{Local, Future} import com.google.caliper.SimpleBenchmark import com.twitter.finagle.zipkin.thrift.ZipkinTracer import com.twitter.finagle.tracing.Annotation.{ServerSend, ServerRecv, Me...
Explain and rewrite the following Scala code:
//https://www.hackerrank.com/challenges/sequence-full-of-colors object FullOfColors extends App { class Deck(var r: Int, var g: Int, var y: Int, var b: Int) { def isPrefixOK = (r - g).abs < 2 && (y - b).abs < 2 def isEqualOK = r == g && y == b } object Deck { def apply(r: Int, g: Int, y: Int, b: Int) ...
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 cwe.scala.library.audit.listener import cwe.scala.library.audit._ import cwe.scala.library.audit.data._ import cwe.scala.library.runtime.io.Logger import cwe.scala.library.runtime.ServiceProvider import java.text.SimpleDateFormat import java.util.Date /** * A simple trace service which uses the underlying cwe...
Explain and rewrite the following Scala code:
/* _ _ _ *\\ ** | (_) | | ** ** ___| |_ __| | ___ clide 2 ** ** / __| | |/ _` |/ _ \\ (c) 2012-2014 Martin Ring ...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.lang package completion import com.intellij.codeInsight.completion.{CompletionParameters, CompletionProvider, CompletionResultSet, InsertionContext} import com.intellij.codeInsight.lookup.{InsertHandlerDecorator, LookupElement, LookupElementDecorator} import com.intellij.openapi.pro...
Explain and rewrite the following Scala code:
package scala.lms package epfl package test3 import common._ import test1._ import test2._ import scala.reflect.SourceContext trait FunctionsExp extends Functions with BaseExp { // shadow trait with same name in core package implicit def funTyp[A:Typ,B:Typ]: Typ[A => B] = { implicit val ManifestTyp(mA) = typ...
Explain and rewrite the following Scala code:
/* * Copyright 2015 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 eva4s /** Mixin solely for the purpose of providing common documentation macros. * * @define end the mutation probability at generation `generations` * @define generationsEvolver amount of generations until the fittest individual is chosen for as the solution * @define generationsMutagen the final gene...
Explain and rewrite the following Scala code:
package org.oc.ld32.level import java.util.{ArrayList, List} import org.lengine.entity.Entity import org.lengine.level.Level import org.lengine.maths.Vec2f import org.oc.ld32.entity.{EntityEnemy, BaguetteEntity, EntityBaguettePiece} import org.oc.ld32.maths.AABB class BaguetteLevel(name: String) extends Level { v...
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"); y...
Explain and rewrite the following Scala code:
package lila.setup import chess.{ Mode, Clock } import lila.rating.RatingRange import lila.game.{ Game, Player, Source } import lila.lobby.Color import lila.rating.RatingRange private[setup] case object ApiConfig extends Config { val color = Color.White val variant = chess.variant.Standard val mode = Mode.Casu...
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 not u...
Explain and rewrite the following Scala code:
object A { val x = 3 }
Explain and rewrite the following Scala code:
package dpla.ingestion3.harvesters.oai.refactor import org.apache.spark.sql.SQLContext import org.apache.spark.sql.sources.RelationProvider /** * Entry point for the data source. Uses OaiConfiguration and the parameters to decide which * type of harvest to run, and runs it. */ class DefaultSource extends Relat...
Explain and rewrite the following Scala code:
object Test { def main(args: Array[String]) { val lst = List(1, 2, 3, 4, 5) assert(lst.scanLeft(0)(_ + _) == List(0, 1, 3, 6, 10, 15)) assert(lst.scanRight(0)(_ + _) == List(15, 14, 12, 9, 5, 0)) val emp = List[Int]() assert(emp.scanLeft(0)(_ + _) == List(0)) assert(emp.scanRight(0)(_ +...
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:
/* * MUSIT is a museum database to archive natural and cultural history data. * Copyright (C) 2016 MUSIT Norway, part of www.uio.no (University of Oslo) * * This program 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 Softw...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2014 - 2019 Dennis Vriend <https://github.com/dnvriend> * Copyright (C) 2019 - 2021 Lightbend Inc. <https://www.lightbend.com> */ package akka.persistence.jdbc.state.scaladsl import scala.concurrent.Future import scala.concurrent.duration._ import com.typesafe.config.{ Config, ConfigFactory } i...
Explain and rewrite the following Scala code:
package chana.timeseries.indicator /** * Class for defining indicator's factor * * @author Caoyuan Deng * @Note * If you use Factor in indicator, please considerate AbstractIndicator#InnerFactor first * which will be added to Indicator's factors automatically when new it. */ class Factor( var name: String, ...
Explain and rewrite the following Scala code:
package com.twitter.finatra.http.integration.multiserver.test import com.google.inject.testing.fieldbinder.Bind import com.twitter.finagle.http.{Request, Status} import com.twitter.finatra.http.integration.multiserver.add2server.Add2Server import com.twitter.finatra.http.test.{HttpMockResponses, EmbeddedHttpServer} im...
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 Test extends App { val foos = (1 to 1000).toSeq try { foos.par.map(i => if (i % 37 == 0) throw new MultipleOf37Exception(i) else i) assert(false) } catch { case ex: MultipleOf37Exception => assert(ex.getSuppressed.size > 0) assert(ex.getSuppressed.forall(_.isInstanceOf[MultipleOf37E...
Explain and rewrite the following Scala code:
package oriana import java.io.IOException import akka.actor.PoisonPill import akka.util.Timeout import org.scalatest.{FlatSpec, Matchers} import oriana.testdatabase.DBContext import slick.dbio.{DBIOAction, Effect, NoStream} import scala.concurrent.duration._ import scala.concurrent.{Await, Future} import scala.util....
Explain and rewrite the following Scala code:
def f = { val a: Array[Null] = Array(null) // error: No ClassTag available for Null } def g = { import scala.language.unsafeNulls val a: Array[Null] = Array(null) // error: No ClassTag available for Null }
Explain and rewrite the following Scala code:
package handlers.server import handlers.GameClient import handlers.packets.{PacketWriter, ServerCodes} import scala.concurrent.Future /** * Created by franblas on 15/04/17. */ class PlayerInitFinished(gameClient: GameClient) { def process(): Future[Array[Byte]] = { val writer = new PacketWriter(ServerCodes...
Explain and rewrite the following Scala code:
package coursier.cli.options import java.io.File import caseapp.{ExtraName => Short, HelpMessage => Help, ValueDescription => Value, _} import cats.data.{NonEmptyList, Validated, ValidatedNel} import cats.implicits._ import coursier.cache.CacheDefaults import coursier.cli.params.CacheParams import coursier.credential...
Explain and rewrite the following Scala code:
/* * Scala (https://www.scala-lang.org) * * Copyright EPFL and Lightbend, Inc. * * Licensed under Apache License 2.0 * (http://www.apache.org/licenses/LICENSE-2.0). * * See the NOTICE file distributed with this work for * additional information regarding copyright ownership. */ package scala package reflect ...
Explain and rewrite the following Scala code:
package app.restlike.rim import app.restlike.common.{History, Script, Tracker} import net.liftweb.common.Full import net.liftweb.http._ import net.liftweb.http.rest.RestHelper import org.json4s.native.JsonMethods import server.ServiceFactory object Rim extends RestHelper { import app.restlike.common.Responder._ ...
Explain and rewrite the following Scala code:
package pl.ekodo.crawler import com.typesafe.scalalogging.slf4j.Logging case class MockObject(id: String, body: String) class MockDao extends DAO[MockObject] with Logging { private var map = Map[String, MockObject]() def find(id: String): Option[MockObject] = map.get(id) def save(t: MockObject) = { map ...
Explain and rewrite the following Scala code:
package scaladci package examples import org.specs2.mutable.Specification /* Shopping cart example (version 5) - (Non-DCI?) Centralized Mediator model This version re-introduces more Roles reflecting the participants of a richer mental model drawn from both the user and application programmers mental models. Each UC...
Explain and rewrite the following Scala code:
import java.io.ByteArrayInputStream import java.nio.charset.{Charset, CharsetDecoder, CodingErrorAction, StandardCharsets} import java.util import org.junit.Test import org.scalatest.junit.AssertionsForJUnit import scala.io.{BufferedSource, Codec, Source} /** * @author ynupc * Created on 2015/12/20 */ ...
Explain and rewrite the following Scala code:
package example class `local-file/*<-example::`local-file`#*/` { locally/*->scala::Predef.locally().*/ { val local/*<-local0*/ = 42 local/*->local0*/ +/*->scala::Int#`+`(+4).*/ 4 } }
Explain and rewrite the following Scala code:
package com.signalcollect.dcop.evaluation import java.math.MathContext import java.util.Locale import scala.collection.GenTraversableOnce import scala.collection.generic.Growable import scala.collection.immutable import scala.collection.mutable import scala.io.Source import scala.math.BigDecimal import sca...
Explain and rewrite the following Scala code:
// copy from https://github.com/xuwei-k/httpz // license: MIT // author: Kenji Yoshida <https://github.com/xuwei-k> package httpz import unfiltered.request._ import unfiltered.response._ import unfiltered.filter.Plan.Intent import scala.util.Random object TestServer extends unfiltered.filter.Plan { private[this] ...
Explain and rewrite the following Scala code:
/*********************************************************************** * Copyright (c) 2013-2018 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 org.bidpulse import java.util.UUID.randomUUID import akka.actor.{Terminated, PoisonPill, ActorSystem} import com.typesafe.config.ConfigFactory import org.bidpulse.domain.{ProjectUpdate, InList, Trash, Projects} import org.bidpulse.pipeline.Channel._ import org.bidpulse.pipeline.Channel import org.scalatest.{B...
Explain and rewrite the following Scala code:
/* * Copyright 2019 Spotify AB. * * 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:
/* * 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 scalariform.gui import java.awt.event._ import java.awt.{ List ⇒ _, _ } import javax.swing._ import javax.swing.text._ import javax.swing.event._ import javax.swing.tree._ import javax.swing.table._ import javax.swing.border.TitledBorder import net.miginfocom.layout._ import net.miginfocom.swing._ import sc...
Explain and rewrite the following Scala code:
/* * SPDX-License-Identifier: Apache-2.0 * * Copyright 2015-2021 Andre White. * * 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 * * https://www.apache.org/licenses/LICENSE-2.0 * ...
Explain and rewrite the following Scala code:
package util object CollectionUtils { /** * * @param collection * @param key * @param compare * @tparam T * @tparam K * @tparam V * @return Map of keys of duplicate objects. Value is the original object that is duplicated. */ def findDuplicates[T, K, V](collection: Seq[T])(key:...
Explain and rewrite the following Scala code:
package fpinscala.gettingstarted import scala.annotation.tailrec // A comment! /* Another comment */ /** A documentation comment */ object MyModule { def abs(n: Int): Int = if (n < 0) -n else n private def formatAbs(x: Int) = { val msg = "The absolute value of %d is %d" msg.format(x, abs(x)) } ...
Explain and rewrite the following Scala code:
package com.typesafe.slick.testkit.tests import com.typesafe.slick.testkit.util.{AsyncTest, JdbcTestDB} import slick.jdbc.DerbyProfile class InsertTest extends AsyncTest[JdbcTestDB] { import tdb.profile.api._ def testSimple = { class TestTable(tag: Tag, tname: String) extends Table[(Int, String)](tag, tname)...
Explain and rewrite the following Scala code:
package io.truthencode.ddo.subscription import io.truthencode.ddo.subscription.service.{EchoClient, EchoServer} import org.scalatest.BeforeAndAfterAll import org.scalatest.funspec.AnyFunSpec import org.scalatest.matchers.should.Matchers import java.io.IOException class EchoTestScala extends AnyFunSpec with Matchers ...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala package lang package psi package impl package expr import org.jetbrains.plugins.scala.lang.psi.ScalaPsiElementImpl import com.intellij.lang.ASTNode import org.jetbrains.plugins.scala.lang.psi.api.expr._ import types.result.{Success, TypeResult, Failure, TypingContext} import types._...
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:
/* * Copyright (C) 2016-2017 Lightbend Inc. <http://www.lightbend.com> */ package akka.persistence.cassandra.query.scaladsl import akka.actor.Props import akka.persistence.cassandra.query.TestActor import akka.persistence.cassandra.{ CassandraLifecycle, CassandraMetricsRegistry, CassandraSpec } import akka.persiste...