instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
package jp.itohiro.kata.scala import org.scalatest.FunSuite class FpInScalaKata extends FunSuite { test("formatResult function should format.") { assert("The absolute value of -42 is 42" == FpInScala.formatResult("absolute value", -42, FpInScala.abs)) assert("The factorial of 4 is 24" == FpInScala.formatRe...
Explain and rewrite the following Scala code:
package com.twitter.inject.tests.module import com.google.inject.Provides import com.google.inject.name.{Named, Names} import com.twitter.conversions.time._ import com.twitter.finatra.tests.Prod import com.twitter.inject.{Injector, TwitterModule} object DoEverythingModule extends TwitterModule { // Note: The follo...
Explain and rewrite the following Scala code:
/* * The MIT License * * Copyright (c) 2016 Fulcrum Genomics LLC * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to us...
Explain and rewrite the following Scala code:
package filodb.coordinator.sources import akka.actor.{Actor, ActorRef, Props} import com.opencsv.CSVReader import org.velvia.filo.{ArrayStringRowReader, RowReader} import scala.util.Try import filodb.coordinator.{BaseActor, NodeCoordinatorActor, RowSource} object CsvSourceActor { // Needs to be a multiple of chunk...
Explain and rewrite the following Scala code:
/* * Copyright 2016 Coursera 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:
package ca.uwaterloo.gsd.rangeFix import Expression._ import Kconfig._ import collection._ import org.kiama.rewriting.Rewriter import gsd.linux.{ KConfigParser, AChoice, And => KAnd, Or => KOr, Eq => KEq, NEq => KNEq, Not => KNot, NonCanonEq, Group, Id, KHex, KInt, Literal => KLiteral, Yes, No, Mod => Module, KExpr, ...
Explain and rewrite the following Scala code:
package lila.security import scala.collection.JavaConversions._ import akka.actor.{ ActorRef, ActorSystem } import com.typesafe.config.Config import scala.concurrent.duration._ import lila.common.PimpedConfig._ import lila.db.Types.Coll import lila.user.{ User, UserRepo } final class Env( config: Config, ca...
Explain and rewrite the following Scala code:
import play.api.mvc.{RequestHeader, WithFilters} import play.filters.gzip.GzipFilter import play.api.mvc.Results._ import scala.concurrent.Future /** * web * User: markbe * Date: 9/11/14 * Time: 2:04 PM */ object Global extends WithFilters(new GzipFilter(shouldGzip = (request, response) => response.headers.get...
Explain and rewrite the following Scala code:
package com.github.jeroenr.tepkin.auth import akka.actor.{Actor, ActorLogging, ActorRef} import com.github.jeroenr.tepkin.MongoCredentials trait NoAuthentication extends Authentication { this: Actor with ActorLogging => override def authenticate(connection: ActorRef, databaseName: String, credentials: Option[Mon...
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 io.youi.theme trait VideoViewTheme extends HTMLComponentTheme { lazy val video: StyleProp[Video] = style[Video]("video", Video.empty, Some(VideoViewTheme)) lazy val autoPauseOnHide: StyleProp[Boolean] = style[Boolean]("autoPauseOnHide", true, None) } object VideoViewTheme extends StyleConnect[Video] { o...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala package lang package psi package api package base package types /** * @author Alexander Podkhalyuzin * Date: 22.02.2008 */ trait ScCompoundTypeElement extends ScTypeElement { def components : Seq[ScTypeElement] = findChildrenByClassScala(classOf[ScTypeElement]).toSeq def refin...
Explain and rewrite the following Scala code:
package scalaz.stream import java.util.concurrent.atomic._ import scalaz.Nondeterminism import scalaz.\\/ import scalaz.\\/._ object Merge { type Partial[+A] = Throwable \\/ A import Process._ def mergeN[F[_]:Nondeterminism,A](p: Process[F, Process[F, A]]): Process[F, A] = { def go(k: Key[F, Process[F,A]]...
Explain and rewrite the following Scala code:
package system import play.api.{Application, GlobalSettings, Logger} object Global extends GlobalSettings{ override def onStart(app: Application): Unit = { super.onStart(app) Logger.info("Creating registry and index directories") Production.registry.init() Production.index.init() } }
Explain and rewrite the following Scala code:
// scalac: -Xfatal-warnings -deprecation // import scala.annotation.switch class Foo extends { final val b0 = 5 } with AnyRef { final val b1 = 10 // Using the @switch annotation as a means of testing that the // type inferred for b0 is Int(5) and not Int. Only in the former // case can a switch be generated...
Explain and rewrite the following Scala code:
/****************************************************************************** * Copyright (c) 2014, Equal Experts Ltd * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * 1. Redistributions of ...
Explain and rewrite the following Scala code:
import org.scalatest._ import thesis.dataLoading._ import thesis.matrixTypes._ import thesis.orderings._ import thesis.rectangles._ import thesis.utils._ import thesis._ import breeze.linalg._, eigSym.EigSym import breeze.plot._ import breeze.stats.distributions._ import breeze.stats._ import breeze.numerics._ clas...
Explain and rewrite the following Scala code:
package config /** * Created by salim on 18/09/2016. */ object ConfigDemo extends App { override def main(args: Array[String]): Unit = { printf(Config.foo.toString) } }
Explain and rewrite the following Scala code:
package org.sutemi.sudoku import org.specs2.mutable._ import org.sutemi.sudoku._ class SudokuGridSpec extends Specification { "A SudokuGrid" should { "find cells in the row" in { SudokuGrid.getRowCells(1,3) must beEqualTo(Vector((1,0),(1,1),(1,2),(1,4),(1,5),(1,6),(1,7),(1,8))) } "find cells in ...
Explain and rewrite the following Scala code:
package com.github.agourlay.cornichon.http.server import java.net.NetworkInterface import cats.effect.IO import com.github.agourlay.cornichon.core.CornichonError import org.http4s.HttpRoutes import org.http4s.server.Router import org.http4s.blaze.server.BlazeServerBuilder import org.http4s.implicits._ import scala.j...
Explain and rewrite the following Scala code:
/* Copyright (C) 2008-2014 University of Massachusetts Amherst. This file is part of "FACTORIE" (Factor graphs, Imperative, Extensible) http://factorie.cs.umass.edu, http://github.com/factorie Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with...
Explain and rewrite the following Scala code:
import com.alanjz.meerkat.Square import com.alanjz.meerkat.moves.Move.PawnAdvance import com.alanjz.meerkat.moves.{PseudoLegalMover, PawnMover} import com.alanjz.meerkat.util.numerics.BitMask import com.alanjz.meerkat.util.position.mutable.{NodeStringBuilder, FENMaskNodeBuilder} /** * Created by alan on 12/15/14. */...
Explain and rewrite the following Scala code:
package fs2 import java.util.concurrent.atomic.AtomicLong import cats.effect.IO import cats.implicits._ import org.scalacheck._ import org.scalatest.concurrent.PatienceConfiguration.Timeout import scala.concurrent.duration._ import TestUtil._ class ResourceSafetySpec extends Fs2Spec with EventuallySupport { "Reso...
Explain and rewrite the following Scala code:
import scala.tools.partest.BytecodeTest // import scala.tools.nsc.util.JavaClassPath // import java.io.InputStream // import scala.tools.asm // import asm.ClassReader // import asm.tree.{ClassNode, InsnList} // import scala.collection.JavaConverters._ object Test extends BytecodeTest { def show: Unit = { val cl...
Explain and rewrite the following Scala code:
package com.arcusys.learn.liferay import com.arcusys.learn.liferay.LiferayClasses._ import com.liferay.portal.service.UserLocalServiceUtil import com.liferay.portlet.social.model.BaseSocialActivityInterpreter /** * Created by mminin on 26.06.15. */ trait LBaseSocialActivityInterpreter extends BaseSocialActivityInte...
Explain and rewrite the following Scala code:
package resolve_based_auth import akka.http.scaladsl.model.headers.RawHeader import akka.http.scaladsl.model.{ ContentTypes, FormData, HttpEntity, HttpMethods, HttpRequest, StatusCodes } import akka.http.scaladsl.testkit.ScalatestRouteTest import akka.http.scaladsl.unmarshalling.Unmarshal import com.softwa...
Explain and rewrite the following Scala code:
package lila.user import com.roundeights.hasher.Implicits._ import reactivemongo.api.bson._ import lila.common.NormalizedEmailAddress import lila.db.dsl._ import lila.user.User.{ ClearPassword, PasswordAndToken, BSONFields => F } final class Authenticator( passHasher: PasswordHasher, userRepo: UserRepo )(imp...
Explain and rewrite the following Scala code:
package com.nulabinc.backlog.migration.common.service import com.nulabinc.backlog.migration.common.domain.BacklogSpace /** * @author * uchida */ trait SpaceService { def space(): BacklogSpace def hasAdmin(): Boolean }
Explain and rewrite the following Scala code:
//package nounou.elements.data.filters // //import nounou.elements.NNElement //import nounou.elements.ranges.SampleRangeValid //import nounou.elements.data.{NNDataNull, NNDataAux, NNData} //import nounou.elements.layouts.NNDataLayout //import breeze.linalg.{DenseVector => DV} // ///**This class serves as an "immutable"...
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 leo.datastructures.tptp.tff import leo.datastructures.tptp.Commons._ /** * Created by lex on 3/23/14. */ sealed abstract class Formula case class Logical(formula: LogicFormula) extends Formula { override def toString = formula.toString } case class TypedAtom(formula: String, typ: Type) extends Formula { ...
Explain and rewrite the following Scala code:
package com.datastax.spark.connector.rdd import java.io.IOException import scala.concurrent.Future import com.datastax.spark.connector._ import com.datastax.spark.connector.cql.CassandraConnector import com.datastax.spark.connector.embedded._ import com.datastax.spark.connector.japi.CassandraJavaUtil._ import com.da...
Explain and rewrite the following Scala code:
package com.mesosphere.cosmos import com.mesosphere.cosmos.ItOps._ import com.mesosphere.cosmos.converter.Response._ import com.mesosphere.cosmos.thirdparty.marathon.model.AppId import com.mesosphere.cosmos.util.RoundTrip import com.twitter.bijection.Conversion.asMethod import java.util.UUID import org.scalatest.Featu...
Explain and rewrite the following Scala code:
package com.olvind package requiresjs import ammonite.ops.{Path, exists} case class ResolvedPath(file: Path, folder: Path) object ResolvePath { def apply(p: Path, indexNames: Set[String]): ResolvedPath = if (exists(p)) { if (p.isDir) { val file = indexNames.find { name => (p / name).toI...
Explain and rewrite the following Scala code:
package ilc.util object Util { def assertType[T](t: T) {} def assertTypeAndRet[T](t: T) = t }
Explain and rewrite the following Scala code:
package cgta.oscala package util.debugging import cgta.oscala.util.OFormat ////////////////////////////////////////////////////////////// // Copyright (c) 2014 Ben Jackman // All Rights Reserved // please contact ben@jackman.biz // for licensing inquiries // Created by bjackman @ 6/19/14 6:15 PM ////////////////////...
Explain and rewrite the following Scala code:
package ch.uzh.ifi.pdeboer.pplib.process.entities import scala.reflect.ClassTag import scala.reflect.runtime.universe._ /** * Created by pdeboer on 14/12/14. */ class PassableProcessParam[Base <: ProcessStub[_, _]](var params: Map[String, Any] = Map.empty, val factory: Option[ProcessFactory[Base]] = N...
Explain and rewrite the following Scala code:
object Test { def foo(parameter: Int): String = { val varWithType: String = "Not Null" val varWithoutType = "lorem ipsum" var result = varWithType + varWithoutType return result } def parameterizedFoo[T](arg: T): Unit = { val a = arg val at: T = arg val tl: List[T] = List(at) val...
Explain and rewrite the following Scala code:
package lila.pref sealed class PieceSet private[pref] (val name: String) { override def toString = name def cssClass = name } sealed trait PieceSetObject { val all: List[PieceSet] val default: PieceSet lazy val allByName = all map { c => c.name -> c } toMap def apply(name: String) = allByName....
Explain and rewrite the following Scala code:
package io.scalding.approximations.performance import com.twitter.algebird.HyperLogLogAggregator import com.twitter.scalding._ /** * A Scalding job to count unique elements using HLL */ class CountUniqueHLL(args: Args) extends Job(args) { val input = args.getOrElse("input", "datasets/100MillionUnique") val out...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014-2020 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:
package mau.test import scala.concurrent.ExecutionContext.Implicits.global import scala.util.Random import akka.actor.ActorSystem import com.scalapenos.riak._ abstract class MauRiakSpec(val testName: String, val cleanup: Boolean = true) extends MauSpec { implicit val actorSystem = ActorSystem(s"$testName-System") ...
Explain and rewrite the following Scala code:
package controllers.base import play.api.Logger import play.api.mvc.{Result, Request, ActionBuilder} import scala.concurrent.Future /** * Created by chunli * Email:24228685@qq.com * Date:2015-02-13. * Time:下午6:30 */ object LoggingAction extends ActionBuilder[Request]{ override def invokeBlock[A](request: Requ...
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 2013 zhongl * * 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:
package tastytest /** test references to type parameters in an opaque type alias */ object TestVecs extends Suite("TestVecs") { import Vecs._, Vec._ test { val v = Vec.single("Hello") assert(v.safeHead === "Hello") } }
Explain and rewrite the following Scala code:
package builder import play.api.libs.json.{JsArray, JsBoolean, JsLookupResult, JsNumber, JsObject, JsString, JsValue, JsNull} import scala.util.{Failure, Success, Try} /** * Parse numbers and string json values as strings */ object JsonUtil { def validate( json: JsValue, strings: Seq[String] = Nil, ...
Explain and rewrite the following Scala code:
package org.akoshterek.backgammon.move /** * @author Alex * date 20.07.2015. */ sealed trait MoveType { val value: Int } object MoveType { case object MOVE_INVALID extends MoveType {val value: Int = -1} case object MOVE_GAMEINFO extends MoveType {val value: Int = 0} case object MOVE_NORM...
Explain and rewrite the following Scala code:
/** * 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, software * dist...
Explain and rewrite the following Scala code:
/* * Copyright 2011-2017 Chris de Vreeze * * 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 agree...
Explain and rewrite the following Scala code:
package com.krux.hyperion.common import com.krux.hyperion.adt.{ HString, HInt } import com.krux.hyperion.aws.{ AdpRef, AdpHttpProxy } import com.krux.hyperion.expression.EncryptedParameter case class HttpProxy private ( baseFields: BaseFields, hostname: Option[HString], port: Option[HInt], username: Option[HS...
Explain and rewrite the following Scala code:
package beyond.engine.javascript import org.mozilla.javascript.WrapFactory object BeyondWrapFactory extends WrapFactory { // Make instances of String, Number, Boolean and Character directly available // as JavaScript primitive type setJavaPrimitiveWrap(false) }
Explain and rewrite the following Scala code:
package scutil.lang.extension import java.nio.charset.Charset import scala.annotation.tailrec import scala.collection.mutable import scutil.lang._ object StringImplicits extends StringImplicits trait StringImplicits { implicit final class LangStringExt(peer:String) { def toBigIntOption:Option[BigInt] = parseBig...
Explain and rewrite the following Scala code:
package org.bitcoins.rpc.serializers import org.bitcoins.core.crypto.{DoubleSha256Digest, DoubleSha256DigestBE} import org.bitcoins.core.currency.Bitcoins import org.bitcoins.core.number.UInt32 import org.bitcoins.core.protocol.BitcoinAddress import org.bitcoins.core.protocol.ln.currency.MilliSatoshis import org.bitco...
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 2001-2013 Artima, 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 agre...
Explain and rewrite the following Scala code:
import de.guderlei.spray.database.DatabaseConfiguration import de.guderlei.spray.domain.TodoItem import org.specs2.mutable.Specification import spray.testkit.Specs2RouteTest import de.guderlei.spray.api._ import spray.http.StatusCodes._ import java.sql.Timestamp class MyRouteTest extends Specification with Specs2Rout...
Explain and rewrite the following Scala code:
package chapter14 object Exercise7 extends App { sealed abstract class BinaryTree case class Leaf(value: Int) extends BinaryTree case class Node(nodes: BinaryTree*) extends BinaryTree def leafSum(tree: BinaryTree): Int = tree match { case Leaf(value) => value case Node(nodes@_*) => (0 /: nodes) { ...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.debugger.ui import java.util.concurrent.CompletableFuture import com.intellij.debugger.engine.evaluation.EvaluationContext import com.intellij.debugger.ui.tree.render.ClassRenderer import com.sun.jdi.ClassType import com.sun.jdi.Field import com.sun.jdi.ObjectReference import com.s...
Explain and rewrite the following Scala code:
package com.peterpotts.common.sample import org.scalatest.{Matchers, WordSpec} class SampleLiftTest extends WordSpec with Matchers { "A sample lift instance" should { "generate lifted values" in { SampleLift("stone").next() shouldEqual "stone" } } }
Explain and rewrite the following Scala code:
package me.pzang import org.scalatest.{FlatSpec, Matchers} /** * Created by pzang on 4/6/16. */ class ConfigParserTests extends FlatSpec with Matchers { }
Explain and rewrite the following Scala code:
/* * Wire * Copyright (C) 2016 Wire Swiss GmbH * * 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 License, or * (at your option) any later version. * * This progr...
Explain and rewrite the following Scala code:
/** * Copyright 2015 Thomson Reuters * * 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 ag...
Explain and rewrite the following Scala code:
package com.besuikerd.autologistics.common.block import com.besuikerd.autologistics.common.{ModMaterials, ModBlockNames} import com.besuikerd.autologistics.common.tile.{TileLogisticController, TileLogisticCable} import cpw.mods.fml.common.registry.GameRegistry import net.minecraft.init.Blocks import net.minecraft.tile...
Explain and rewrite the following Scala code:
/* sbt -- Simple Build Tool * Copyright 2008, 2009, 2010 Mark Harrah */ package sbt import java.io.{ IOException, File } import java.net.URL import scala.xml.{ Text, NodeSeq, Elem, XML } import org.apache.ivy.plugins.resolver.DependencyResolver import org.xml.sax.SAXParseException sealed trait Resolver { def nam...
Explain and rewrite the following Scala code:
/*** * Copyright 2017 Rackspace US, 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 applica...
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:
/* * (C) 2017 Hortonworks, Inc. All rights reserved. See the NOTICE file * distributed with this work for additional information regarding copyright * ownership. This file is licensed to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. ...
Explain and rewrite the following Scala code:
package me.gregd.cineworld.domain import cats.ApplicativeError package object service { type ApplicativeThrowable[F[_]] = ApplicativeError[F, Throwable] }
Explain and rewrite the following Scala code:
package com.iheart.playSwagger import org.specs2.mutable.Specification class NamingStrategySpec extends Specification { "naming strategy" >> { "none" >> { NamingStrategy.from("none")("attributeName") must be("attributeName") } "snake_case" >> { NamingStrategy.from("snake_case")("attributeN...
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:
package drt.shared.airportconfig import drt.shared.PaxTypes.{B5JPlusNational, B5JPlusNationalBelowEGateAge, EeaBelowEGateAge, EeaMachineReadable, EeaNonMachineReadable, NonVisaNational, VisaNational} import drt.shared.PaxTypesAndQueues._ import drt.shared.Queues.{EGate, EeaDesk} import drt.shared.SplitRatiosNs.{SplitR...
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:
/* * 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 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:
// Databricks notebook source exported at Wed, 3 Jun 2015 05:56:22 UTC import com.databricks.demo.Demo // COMMAND ---------- Demo.run() // COMMAND ----------
Explain and rewrite the following Scala code:
package examples import java.awt.Point import rescala._ import scala.swing.event._ class Mouse { /* EScala events */ val mouseMovedE = Evt[Point] val mousePressedE = Evt[Point] val mouseDraggedE = Evt[Point] val mouseReleasedE = Evt[Point] /* Compose reactive values */ val mouseChangePosition = mouseMove...
Explain and rewrite the following Scala code:
package teleporter.integration.cluster.broker.jdbc import javax.sql.DataSource import org.apache.logging.log4j.scala.Logging import teleporter.integration.cluster.broker.PersistentProtocol.KeyValue import teleporter.integration.cluster.broker.PersistentService import teleporter.integration.component.jdbc.{PreparedSql...
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 2017-2022 John Snow 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 agr...
Explain and rewrite the following Scala code:
package com.reactmq import java.net.InetSocketAddress import akka.actor.{ActorSystem, Props} import akka.stream.actor.{ActorPublisher, ActorSubscriber} import akka.stream.scaladsl._ import akka.util.ByteString import com.reactmq.Framing._ import com.reactmq.queue.{DeleteMessage, MessageData, QueueActor} import scala...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014 Dufresne Management Consulting LLC. */ package com.nickelsoftware.bettercare4me.hedis.hedis2014 import scala.util.Random import org.joda.time.DateTime import org.joda.time.Interval import com.nickelsoftware.bettercare4me.hedis.HEDISRule import com.nickelsoftware.bettercare4me.hedis.HEDISRuleB...
Explain and rewrite the following Scala code:
/* * Copyright 2001-2013 Artima, 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 agre...
Explain and rewrite the following Scala code:
/* It's a common Scala style to write method calls without `.` notation, as in `t() takeWhile f`. */ def takeWhile(f: A => Boolean): Stream[A] = this match { case Cons(h,t) if f(h()) => cons(h(), t() takeWhile f) case _ => empty }
Explain and rewrite the following Scala code:
package skinny.validator import org.scalatest._ import org.joda.time._ class pastSpec extends FlatSpec with Matchers { behavior of "past" it should "be available" in { val validate = past validate.name should equal("past") validate(param("x" -> null)).isSuccess should equal(false) validate(pa...
Explain and rewrite the following Scala code:
package scala.macros package config import scala.macros.internal.config.scalamacros.BuildInfo private[macros] trait Api { private def ensureVersion(key: String, value: String): Version = { def fail = sys.error(s"fatal error reading BuildInfo: $key $value is not a valid version") Version.parse(value).getOrEl...
Explain and rewrite the following Scala code:
package test.thorla package util import thorla.util.Util import org.scalatest.FunSpec /** * Some basic sanity checks for utils */ class UtilSpec extends FunSpec { val arrInt = Array(23, 45, 6, 23, 123, 34, 234, 0, 0) val arrLong = Array(10091922L, 18550745L, 6247315L, 22912610L, 3730331L, 31808932L) describ...
Explain and rewrite the following Scala code:
object SCL3338 { implicit def convert(p: (String, String)): String = p._1.concat(p._2) def foo(p: String) = "text" def foo(i: Int) = 123 /*start*/(foo("xxx", "zzz"), foo(("xxx", "zzz")))/*end*/ } //(String, String)
Explain and rewrite the following Scala code:
package fuel.util import scala.collection.generic.CanBuildFrom /** * Trait intended to enable elegant use of different random number generators */ trait TRandom { def nextBoolean(): Boolean def nextBytes(bytes: Array[Byte]) def nextDouble(): Double def nextFloat(): Float def nextGaussian(): Double def n...
Explain and rewrite the following Scala code:
package mesosphere.marathon package core.matcher.manager.impl import java.util import java.util.concurrent.TimeUnit import akka.pattern.ask import akka.testkit.TestActorRef import akka.util.Timeout import mesosphere.AkkaUnitTest import mesosphere.marathon.core.base.ConstantClock import mesosphere.marathon.core.matche...
Explain and rewrite the following Scala code:
package strd.dht3 import com.google.protobuf.Message import strd.cluster.proto.StrdCluster.RDone import strd.dht.BIN import strd.dht3.proto.StrdDhtCluster._ import strd.net.{RequestContext, StrdProtos} /** * * User: light * Date: 15/04/14 * Time: 12:25 */ trait DhtServerTable { def shutdown() def tableId ...
Explain and rewrite the following Scala code:
package org.codeswarm.fallible /** Represents a value or a list of errors explaining why the value is absent. * Instances of `Fallible[A, E]` are an instance of either `Success[A]` or `Failure[E]`. */ sealed abstract class Fallible[+A, +E] { /** Returns true if this is an instance of `Success`, or false otherwi...
Explain and rewrite the following Scala code:
package pl.setblack.lsa.cryptotpyrc.rsa import pl.setblack.lsa.cryptotpyrc.{PublicKey, PrivateKey, KeyPair} trait RSAPrivateKey extends PrivateKey { } trait RSAPublicKey extends PublicKey { } //type RSAKeyPair = KeyPair[RSAPublicKey, RSAPrivateKey]
Explain and rewrite the following Scala code:
package org.http4s package headers import scalaz.\/._ import org.http4s.ServerSentEvent._ import org.http4s.parser.HttpHeaderParser import org.http4s.util.Writer final case class `Last-Event-Id`(id: EventId) extends Header.Parsed { override def key = `Last-Event-Id` override def renderValue(writer: Writer): write...
Explain and rewrite the following Scala code:
package dpla.ingestion3.dataStorage import org.scalatest._ class DataStorageTest extends FlatSpec { "parseS3Address" should "correctly parse an S3 protocol" in { val path = "s3a://my-bucket/foo/bar/" assert(parseS3Address(path).protocol == "s3a") } "parseS3Address" should "correctly parse an S3 bucket...
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:
// Databricks notebook source // MAGIC %md // MAGIC // MAGIC ## Scalable web scrapper -- Based on MS4DS book (Chap. 6) // MAGIC // MAGIC This cleaned up notebook will contain code to perform web scraping, which should then be called from another notebook // COMMAND ---------- // MAGIC %md Need to install the goose...
Explain and rewrite the following Scala code:
/* NSC -- new Scala compiler * Copyright 2005-2011 LAMP/EPFL * @author Paul Phillips */ package improving import PostMortemTracer._ import scala.collection.{ mutable, immutable } /** A class which stores all the calls to indicated methods * without outputting anything until the jvm shuts down. * This way we ...
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 ...