instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
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: | /*
* 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 sharednodejsapis
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
@js.native
@JSImport("electron", "ipcRenderer")
object IPCRenderer extends EventEmitter {
def send(channel: String, args: Any*): Unit = js.native
def sendSync(channel: String, args: Any*): Any = js.native
... |
Explain and rewrite the following Scala code: | package io.ddf.flink.content
import java.util
import java.util.{List, Map}
import io.ddf.content.Schema.{ColumnType, Column}
import io.ddf.content.{IHandleRepresentations, Schema}
import io.ddf.exception.DDFException
import io.ddf.{DDF, Factor}
import org.apache.flink.api.scala.DataSet
import org.apache.flink.api.sca... |
Explain and rewrite the following Scala code: | /* Generated File */
package models.doobie.film
import com.kyleu.projectile.services.database.doobie.DoobieQueryService.Imports._
import models.film.MpaaRatingType
object MpaaRatingTypeDoobie {
implicit val mpaaRatingTypeMeta: Meta[MpaaRatingType] = pgEnumStringOpt("MpaaRatingType", MpaaRatingType.withValueOpt, _.v... |
Explain and rewrite the following Scala code: |
package utils
import scalaz._
import Scalaz._
/**
* @author rajthilak
*
*/
object StringStuff {
def NilOrNot(rip: String, aor: String): String = {
rip == null || rip == "" match {
case true => return aor
case false => return rip
}
}
}
|
Explain and rewrite the following Scala code: | case class Check[A](val value: A)
case class C2(checks: Check[_]*);
object C {
def m(x : C2): Any = (null: Any) match {
case C2(_, rest : _*) => {
// Invalid: Vararg pattern cannot be split between normal and :_* patterns.
// This split also does not work for vararg arguments, so there's no
// good ... |
Explain and rewrite the following Scala code: | package models.template
object Icons {
/* Start model icons */
/* Projectile export section [boilerplay] */
val pkg_address = "watch"
val pkg_customer = "opacity"
val pkg_film = "cached"
val pkg_payment = "storage"
val pkg_store = "code"
val actorRow = "videogame_asset"
val addressRow = "storage"
v... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2009-2017 Lightbend Inc. <https://www.lightbend.com>
*/
package play.core.server
import java.io.File
import java.util.Properties
import org.specs2.mutable.Specification
import play.core.ApplicationProvider
class ServerConfigSpec extends Specification {
"ServerConfig construction" should {
... |
Explain and rewrite the following Scala code: | /* Copyright 2009-2021 EPFL, Lausanne */
object Sequencing7 {
def test(): Int = {
var x = 5
{x = x + 1; x}
{x = x * 2; x}
{x = x - 1; x}
x
} ensuring(res => res == 11)
}
|
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2014-2015 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apach... |
Explain and rewrite the following Scala code: | package com.github.diegopacheco.scala.playground.akka.cluster.frontend.backend
import com.typesafe.config.ConfigFactory
import akka.actor.Actor
import akka.actor.ActorSystem
import akka.actor.Props
import akka.cluster.Cluster
import akka.cluster.routing.ClusterRouterPool
import akka.cluster.routing.ClusterRouterPoolSe... |
Explain and rewrite the following Scala code: | import de.wayofquality.sbt.filterresources.FilterResources
import de.wayofquality.sbt.filterresources.FilterResources.autoImport._
import sbt._
import de.wayofquality.sbt.testlogconfig.TestLogConfig.autoImport._
import blended.sbt.Dependencies
object BlendedFile extends ProjectFactory {
private[this] val helper = n... |
Explain and rewrite the following Scala code: | package scravatar
import java.net.{URI, URL, URLEncoder}
/**
* Immutable (thread safe) class used to generate Gravatar URLs
* @author Morten Andersen-Gott - code@andersen-gott.com
*/
case class Gravatar(
private val emailAddress: String,
ssl: Boolean = false,
forceDefault: Boolean ... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) Lightbend Inc. <https://www.lightbend.com>
*/
package play.api.libs.streams
import akka.NotUsed
import akka.actor.ActorSystem
import akka.stream.scaladsl.Flow
import akka.stream.scaladsl.Sink
import akka.stream.scaladsl.Source
import akka.stream.Materializer
import org.reactivestreams.Subscriber
... |
Explain and rewrite the following Scala code: | /*
We get back the original list! Why is that? One way of thinking about what `foldRight` "does" is it replaces the `Nil` constructor of the list with the `z` argument, and it replaces the `Cons` constructor with the given function, `f`. If we just supply `Nil` for `z` and `Cons` for `f`, then we get back the input li... |
Explain and rewrite the following Scala code: | package com.aluxian.tweeather.scripts
import com.aluxian.tweeather.RichBoolean
import org.apache.spark.Logging
import org.apache.spark.sql.SaveMode
/**
* Created by Najeefa Nikhat Choudhury
* This script parses the tweets collected by [[TwitterEmoByCountry]].
* It removes duplicates and tweets which contain bot... |
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.tools.nsc
packag... |
Explain and rewrite the following Scala code: | /*
* Copyright 2015 Webtrends (http://www.webtrends.com)
*
* See the LICENCE.txt 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: | package scala.async.tests
import Util._
import org.junit.Test
import scala.async.Join._
import rx.lang.scala.Observable
class JoinResultTests {
@Test
def joinResultImplementedCorrectly() = {
val input = (1 to randomNonZeroEvenInteger(maxListSize)).toList
val o1 = Observable.just(input: _*).p
var re... |
Explain and rewrite the following Scala code: | package edu.berkeley.veloxms.util
import breeze.linalg.{DenseMatrix, DenseVector}
import edu.berkeley.veloxms._
import org.apache.spark.rdd.RDD
object UserWeightUpdateMethods extends Serializable {
val lambda = 1.0
/**
* Naive Implementation
* TODO: Optimize this bulk calculation & Make this much more effi... |
Explain and rewrite the following Scala code: | package de.frosner.ddq.reporters
import java.util.Date
import de.frosner.ddq.constraints._
import de.frosner.ddq.core.CheckResult
import org.apache.log4j.{Level, Logger}
import scala.util.parsing.json.{JSONArray, JSONObject}
case class Log4jReporter(logger: Logger = Logger.getLogger("DDQ"), logLevel: Level = Level.... |
Explain and rewrite the following Scala code: | /*
* Copyright 2018 Zhang Di
*
* 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: | package com.cyberthinkers.scalajs.tools.generate
import scala.collection.mutable
trait TypeScriptId {
val identifier: String
}
object AccessibilityModifiers {
val publicModifier = 1 // default is public
val protectedModifier = 2
val privateModifier = 4
val staticModifier = 8
val readonlyModifier = 16
v... |
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 nars.entity
import java.util.ArrayList
import nars.gui.ConceptWindow
import nars.inference.BudgetFunctions
import nars.inference.LocalRules
import nars.inference.RuleTables
import nars.inference.UtilityFunctions
import nars.language.CompoundTerm
import nars.language.Term
import nars.main.NARS
import nars.main.... |
Explain and rewrite the following Scala code: |
object TypeClazz102 extends App {
import scalaz._
import Scalaz._
case class TrafficLight(name: String)
val red = TrafficLight("red")
val yellow = TrafficLight("yellow")
val green = TrafficLight("green")
implicit val TrafficLightEqual:Equal[TrafficLight] = Equal... |
Explain and rewrite the following Scala code: | package cmdreader
import scala.collection.mutable.HashMap
class CmdOpList(libname: String) {
def getLib(): String = libname
var opList: HashMap[String, CommandOperator] = new HashMap[String, CommandOperator]()
def loadOp(c: CommandOperator) {
val opn = c.getOpAlias
opList(opn) = c
println(s"Loaded o... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2014-2021 All Rights Reserved by the RWS Group for and on behalf of its affiliates and subsidiaries.
*
* 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://w... |
Explain and rewrite the following Scala code: | package sword.langbook.android.activities
object RequestCodes {
val addNewWord = 1
val checkWordDetails = 2
val pickConceptsForSynonym = 3
val pickConceptsForTranslation = 4
val pickFileRead = 5
val pickFileWrite = 6
val pickLanguage = 7
}
|
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: | /**
* ____ __ ____ ____ ____,,___ ____ __ __ ____
* ( _ \\ /__\\ (_ )(_ _)( ___)/ __) ( _ \\( )( )( _ \\ Read
* ) / /(__)\\ / /_ _)(_ )__) \\__ \\ )___/ )(__)( ) _ < README.txt
* (_)\\_)(__)(__)(____)(____)(____)(___/ (__) (______)(____/ LICENSE.txt
... |
Explain and rewrite the following Scala code: | class i0[@specialized i1] {
def i2[i3[_]](i4: i1 => i3[Nothing]): i2[Int] = ???
implicit def i5[i2](i6: i0[i1, i2]) = ???
implicit def i5(implicit i3: i1[Int]): String => String = {
val i6: i2 = new i0[Int] { def i7(i5: Int) = 0 }
val i1 = i2 == i2 match { case i1[i2](i3, i6) =>
def this(i6: Array[String]) = i3 _
}
}
t... |
Explain and rewrite the following Scala code: | package edu.rice.habanero.actors
import java.util.concurrent.atomic.AtomicBoolean
import edu.rice.hj.runtime.config.HjSystemProperty
import edu.rice.hj.runtime.util.ModCountDownLatch
import groovyx.gpars.actor.DefaultActor
import groovyx.gpars.actor.impl.MessageStream
import groovyx.gpars.group.DefaultPGroup
import g... |
Explain and rewrite the following Scala code: | package io.github.mandar2812.dynaml.tensorflow.dynamics
import io.github.mandar2812.dynaml.pipes._
import io.github.mandar2812.dynaml.DynaMLPipe._
import io.github.mandar2812.dynaml.tensorflow.models.TFModel
import io.github.mandar2812.dynaml.tensorflow._
import io.github.mandar2812.dynaml.tensorflow.layers.{
PDEQua... |
Explain and rewrite the following Scala code: | package org.kimbasoft.specs2.scalacheck
import org.specs2.execute.ResultImplicits._
import org.specs2.specification.core.SpecStructure
import org.specs2.{Specification, ScalaCheck}
/**
* Missing documentation.
*
* @author <a href="steffen.krause@soabridge.com">Steffen Krause</a>
* @since 1.0
*/
class Specs2Scal... |
Explain and rewrite the following Scala code: | package iot.pood.storage
import java.util.Calendar
import akka.actor.{ActorRef, ActorSystem, Props}
import iot.pood.base.app.{ActorApp, ConfigurableApp, HttpApp}
import iot.pood.base.config.{Configuration, HttpConfig}
import iot.pood.base.http.base.ApiVersionService
import iot.pood.base.http.health.HealthHttpService
... |
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: | package se.ramn.bottfarmen.simulation
import collection.JavaConverters._
import collection.immutable.Iterable
import collection.immutable.Seq
import collection.immutable.IndexedSeq
import util.Random
import se.ramn.bottfarmen.api
import se.ramn.bottfarmen.simulation.entity.Bot
import se.ramn.bottfarmen.simulation.ent... |
Explain and rewrite the following Scala code: | package me.verticale.imgur
import dispatch._
import Defaults._
import org.json4s._
import me.verticale.imgur.model._
import org.json4s.native.JsonMethods._
/** Imgur API client
*
* @constructor Create new Imgur API client
* @param clientId Client identifier
* @param baseUrl API's base URL, default "api.imgur.... |
Explain and rewrite the following Scala code: | import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.annotation.ComponentScan
import org.springframework.web.bind.annotation.{RequestMapping, RestController}
import org.springframework.boot._;
import org.springframewor... |
Explain and rewrite the following Scala code: | package uk.co.sprily
package btf.web
package controllers
import com.google.common.net.InetAddresses
import com.typesafe.scalalogging.LazyLogging
import play.api.data._
import play.api.data.Forms._
import play.api.data.validation._
import play.api.mvc._
import play.api.mvc.BodyParsers.parse
import uk.co.sprily.dh.mo... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2014 Robert Conrad - All Rights Reserved.
* Unauthorized copying of this file, via any medium is strictly prohibited.
* This file is proprietary and confidential.
* Last modified by rconrad, 12/24/14 4:37 PM
*/
package base.common.test
import org.scalatest.Tag
/**
* Scalatest tags to be used... |
Explain and rewrite the following Scala code: | package com.estus.optimization
import com.estus.optimization.MessageProtocol._
import org.apache.commons.math3.distribution.CauchyDistribution
import akka.actor.{Props, ActorLogging, Actor, ActorRef}
import akka.routing.RoundRobinPool
import scala.concurrent.duration.Duration
import scala.util.Random
class DEAct... |
Explain and rewrite the following Scala code: | package es.udc.graph.test
//import org.specs2.mutable.Specification
import es.udc.graph.utils.GraphUtils._
import es.udc.graph.utils.Selection._
import scala.runtime.RichInt
import scala.util.Random
/**
* Created by davidmartinezrego on 06/11/15.
*/
class GraphUtilsTest{/* extends Specification{
"medianUpTo5" ... |
Explain and rewrite the following Scala code: | package dotty.tools.dottydoc
package util
package internal
object setters {
import model._
import comment.Comment
import internal._
def setComment(ent: Entity, to: Option[Comment]) = ent match {
case x: PackageImpl => x.comment = to
case x: ClassImpl => x.comment = to
case x: CaseClassImpl =... |
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.goodmath.apog.view
import org.goodmath.apog.rope.{Rope, RopeBuffer}
import org.scalatest._
class ScreenGridSuite extends FunSuite {
test("empty grid") {
val s = new SimpleScreenGrid(4, 10)
assert((
"[____________________]\\n" +
"[____________________]\\n" +
"[______________... |
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 agwlvssainokuni
*
* 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: | package jp.co.dzl.example.akka.api.handler
import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.server.Directives._
import de.heikoseeberger.akkahttpcirce.CirceSupport
import jp.co.dzl.example.akka.api.response.MessageResponse
import io.circe.generic.auto._
class RootHandler(handlers: List[Handler]... |
Explain and rewrite the following Scala code: | /*§
===========================================================================
Chronos
===========================================================================
Copyright (C) 2015-2016 Gianluca Costa
===========================================================================
Licensed under the Apache Lic... |
Explain and rewrite the following Scala code: | package service
import adapter.BitFlyer
import akka.actor.Actor
import application.retry
import com.google.inject.Inject
import domain.margin.Margin
import domain.strategy.Strategies
import play.api.{Configuration, Logger}
import repository.UserRepository
class PositionSizeAdjustmentActor @Inject()(config: Configurat... |
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: | /**
* 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: | package org.jetbrains.bsp
import com.intellij.openapi.actionSystem.{AnAction, AnActionEvent}
import com.intellij.openapi.ui.MessageType
import com.intellij.openapi.util.registry.Registry
class EnableBspAction extends AnAction {
def actionPerformed(e: AnActionEvent): Unit = {
Registry
.get(BSP.RegistryKeyF... |
Explain and rewrite the following Scala code: | import org.scalatest.{Matchers, GivenWhenThen, FeatureSpec}
import Utils._
class ScalaFormalCROMSpec extends FeatureSpec with GivenWhenThen with Matchers {
info("Test spec for ScalaFormalCROM.")
feature("Testing util functions") {
scenario("Testing function for mutually disjoint Lists") {
mutualDisjoint... |
Explain and rewrite the following Scala code: | package com.github.ghik.silencer
trait SilencerPluginCompat { this: SilencerPlugin =>
import global._
protected object MaybeNamedArg {
def unapply(tree: Tree): OptRef[Tree] = tree match {
case AssignOrNamedArg(_, rhs) => OptRef(rhs)
case _ => OptRef(tree)
}
}
}
|
Explain and rewrite the following Scala code: | package skinny
import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers
import java.util.Locale
class I18nSpec extends FlatSpec with ShouldMatchers {
behavior of "I18n"
it should "be available" in {
val i18n = I18n()
i18n.get("name") should equal(Some("Name"))
i18n.get("foo.name") ... |
Explain and rewrite the following Scala code: | package com.krux.hyperion.resource
import com.krux.hyperion.common.{ PipelineObject, HttpProxy, NamedPipelineObject }
import com.krux.hyperion.adt.{ HString, HBoolean, HDuration }
/**
* The base trait of all resource objects.
*/
trait ResourceObject extends NamedPipelineObject {
type Self <: ResourceObject
de... |
Explain and rewrite the following Scala code: | /*
* Copyright 2012 Alexander Bertram
*
* 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 TurboRav
import Chisel._
import Constants._
class SocTest(c: Soc) extends JUnitTester(c) {
poke(c.io.pin_inputs, 2)
step(100 * 1000)
printRegs()
// Could easily do something similair with the memory when we want
// to.
private def printRegs() = {
val regs = Array.ofDim[BigInt](32)
for(i ... |
Explain and rewrite the following Scala code: | /*
* Copyright 2011-2021 Asakusa Framework Team.
*
* 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 ... |
Explain and rewrite the following Scala code: | package filodb.core.downsample
import com.typesafe.config.{Config, ConfigFactory}
import net.ceedubs.ficus.Ficus._
final case class DownsampleConfig(config: Config) {
val enabled = config.hasPath("enabled") && config.getBoolean("enabled")
val resolutions = if (enabled) config.as[Seq[Int]]("resolutions-ms") else S... |
Explain and rewrite the following Scala code: | package xmppz
import packet._
trait Packet {
def source: String = ""
def children: Seq[Packet]
//TODO: make tail recursive?
final def collect[T <: Packet](pf: PartialFunction[Packet, T]): Option[T] = {
val first = children.collect(pf).headOption
first match {
case Some(f) => Some(f)
case ... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala.lang.psi.types.api.presentation
import org.jetbrains.plugins.scala.lang.lexer.ScalaTokenTypes
import org.jetbrains.plugins.scala.lang.psi.api.statements.params.{ScTypeParam, ScTypeParamClause}
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.{ScTypeBoundsOwner, ScTypeParamet... |
Explain and rewrite the following Scala code: | package com.ubirch.avatar.core.device
import java.util.UUID
import com.typesafe.scalalogging.StrictLogging
import com.ubirch.avatar.config.Config
import com.ubirch.avatar.model.rest.device.{DeviceHistory, DeviceHistoryLegacy}
import com.ubirch.util.elasticsearch.util.SortBuilderUtil
import com.ubirch.util.elasticsear... |
Explain and rewrite the following Scala code: |
import org.scalatest.FunSuite
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class ConjuntoFuncionalSuite extends FunSuite {
// Se importan las declaraciones en ConjuntoFuncional
import ConjuntoFuncional._
// Se crea un trait incluyendo tres conjuntos,... |
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 com.kakao.mango.elasticsearch
import com.kakao.mango.http._
import com.kakao.mango.json._
import scala.concurrent.Future
/**
* A client for ElasticSearch, using its HTTP API.
* This may be less efficient than its Java API,
* but keeps the JVM classpath free of ElasticSearch and Lucene jars.
*
* @pa... |
Explain and rewrite the following Scala code: | package lila.study
import chess.format.UciCharPair
case class Path(ids: List[UciCharPair]) extends AnyVal {
def head: Option[UciCharPair] = ids.headOption
def tail: Path = Path(ids drop 1)
def split: Option[(UciCharPair, Path)] = head.map(_ -> tail)
def isEmpty = ids.isEmpty
def +(node: Node) = Path(id... |
Explain and rewrite the following Scala code: | package xyz.driver.tracing
package google
import java.nio.ByteBuffer
import java.time._
import java.time.format._
import java.util.UUID
import spray.json.DefaultJsonProtocol.{LongJsonFormat => _, _}
import spray.json._
case class TraceSpan(
spanId: Long,
kind: TraceSpan.SpanKind,
name: String,
startT... |
Explain and rewrite the following Scala code: | package pl.touk.nussknacker.ui.security.api
object Permission extends Enumeration {
type Permission = Value
val Read = Value("Read")
val Write = Value("Write")
val Deploy = Value("Deploy")
val Demo = Value("Demo")
final val ALL_PERMISSIONS = Set(Read, Write, Deploy, Demo)
}
|
Explain and rewrite the following Scala code: | package com.avast.metrics.scalaeffectapi.impl
import cats.effect.Sync
import com.avast.metrics.scalaapi.{Meter => SMeter}
import com.avast.metrics.scalaeffectapi.Meter
private class MeterImpl[F[_]: Sync](meter: SMeter) extends Meter[F] {
override def mark: F[Unit] = Sync[F].delay(meter.mark())
override def mark(... |
Explain and rewrite the following Scala code: | package p1 {
object InlineHolder {
@inline def inlinable = p1.PackageProtectedJava_1.protectedMethod() + 1
}
}
object O {
@noinline
def x = p1.InlineHolder.inlinable
}
object Test {
def main(args: Array[String]) {
println(O.x)
}
}
|
Explain and rewrite the following Scala code: | package com.aletrader.brewerydb;
/*
{
"id": "4",
"description": "Available at the same time of year, every year.",
"name": "Seasonal"
}
*/
class Available(
val id: String,
val description: String,
val name: String) {}
|
Explain and rewrite the following Scala code: | package scala.virtualization.lms
package epfl
package test13
import common._
import internal._
import test1._
import test7.{Print,PrintExp,ScalaGenPrint}
import test7.{ArrayLoops,ArrayLoopsExp,ScalaGenArrayLoops}
import test8._
import test10._
import util.OverloadHack
import java.io.{PrintWriter,StringWriter,FileOut... |
Explain and rewrite the following Scala code: | package com.twitter.finagle.ssl
import com.twitter.finagle.Service
import com.twitter.finagle.builder.{ClientBuilder, ServerBuilder}
import com.twitter.finagle.http.Http
import com.twitter.io.TempFile
import com.twitter.util.{Await, Future}
import java.io.File
import java.net.InetSocketAddress
import org.jboss.netty.b... |
Explain and rewrite the following Scala code: | package maker.project
import maker.task.BuildResult
import maker.task.tasks.CreateDeployTask
import maker.utils.FileUtils._
import java.io.File
import maker.MakerProps
import maker.utils.RichString._
case class Project(
name : String,
root : File,
immediateUpstreamModules:List[Module],
props : MakerProps = Ma... |
Explain and rewrite the following Scala code: | package com.twitter.zipkin.storage.redis
import com.google.common.base.Charsets._
import com.twitter.finagle.redis.Client
import com.twitter.scrooge.{CompactThriftSerializer, ThriftStructSerializer}
import com.twitter.util.{Duration, Future}
import com.twitter.zipkin.adjuster.{ApplyTimestampAndDuration, CorrectForCloc... |
Explain and rewrite the following Scala code: | import scala.util.Sorting
//Some Cases Wrong Answer
object Solution extends App {
val sc = new java.util.Scanner (System.in);
var n = sc.nextInt();
var p = sc.nextInt();
var a = new Array[Int](n);
for(a_i <- 0 to n-1) {
a(a_i) = sc.nextInt();
}
a = a.map((x:Int) => (x.toFloat/p).ceil.toInt)
Sortin... |
Explain and rewrite the following Scala code: | package com.twitter.finagle.loadbalancer
import com.twitter.finagle._
import com.twitter.finagle.stats.{InMemoryStatsReceiver, StatsReceiver, NullStatsReceiver}
import com.twitter.util.{Future, Time}
import java.util.concurrent.atomic.AtomicInteger
import org.junit.runner.RunWith
import org.scalacheck.Gen
import org.s... |
Explain and rewrite the following Scala code: | /*
Collector is a tool for obtaining bioactivity data from the Open PHACTS platform.
Copyright (C) 2013 UPF
Contributed by Manuel Pastor(manuel.pastor@upf.edu) and Oriol López-Massaguer(oriol.lopez@upf.edu).
This file is part of Collector.
Collector is free software: you can redistribute i... |
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.sgrouples.rogue.cc
import me.sgrouples.rogue.{BsonFormats, EnumNameFormats}
import org.bson.types.ObjectId
import me.sgrouples.rogue._
import BsonFormats._
import EnumNameFormats._
import me.sgrouples.rogue.cc.Metas.VenueRMeta
import munit.FunSuite
import scala.concurrent.Future
import scala.util.Try
import... |
Explain and rewrite the following Scala code: | /*
Copyright 2016-17, Hasso-Plattner-Institut fuer Softwaresystemtechnik GmbH
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 applicab... |
Explain and rewrite the following Scala code: | package ch05
//3. Write a class Time with read-only properties hours and minutes and a
// method before(other: Time): Boolean that checks whether this time
// comes before the other. A Time object should be constructed as
// new Time(hrs, min), where hrs is in military time format (between
// 0 and 23).
objec... |
Explain and rewrite the following Scala code: | package com.softwaremill.codebrag.usecases.branches
import com.typesafe.scalalogging.slf4j.Logging
import org.bson.types.ObjectId
import com.softwaremill.codebrag.domain.UserWatchedBranch
import com.softwaremill.codebrag.dao.branch.WatchedBranchesDao
import com.softwaremill.codebrag.common.Clock
import com.softwaremil... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2015 Keith M. Hughes.
*
* 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.theseventhsense.utils.types
import cats.implicits._
import java.util
import java.util.Date
import com.theseventhsense.datetime._
import scala.concurrent.duration.Duration
import scala.language.implicitConversions
import scala.util.Try
/**
* Created by erik on 11/11/15.
*/
object SSDateTime {
val d... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2017 Magomed Abdurakhmanov, Hypertino
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
package com.hypertino.hyperbus.config
import com.hy... |
Explain and rewrite the following Scala code: | package spatial.analysis
import argon.core._
import argon.nodes._
import spatial.aliases._
import spatial.models._
import spatial.nodes._
import spatial.metadata._
import spatial.utils._
import virtualized.SourceContext
import scala.collection.mutable
case class AreaAnalyzer(var IR: State, areaModel: AreaModel, late... |
Explain and rewrite the following Scala code: | /***********************************************************************
* Copyright (c) 2013-2022 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: | /* Title: Pure/General/exn.scala
Author: Makarius
Support for exceptions (arbitrary throwables).
*/
package isabelle
object Exn
{
/* user errors */
class User_Error(message: String) extends RuntimeException(message)
{
override def equals(that: Any): Boolean =
that match {
case... |
Explain and rewrite the following Scala code: | package uk.ac.ncl.openlab.intake24.services.fooddb.images
import java.nio.file.Path
trait ImageStorageService {
/**
* Uploads image to the storage service, keeping the source file in place.
*/
def uploadImage(suggestedPath: String, file: Path): Either[ImageStorageError, String]
/**
* Downloads a cop... |
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.jetbrains.plugins.scala.testingSupport.scalatest
/**
* @author Roman.Shein
* @since 04.09.2015.
*/
trait ScalaTestPackageTest extends ScalaTestTestCase {
protected val packageName = "myPackage"
protected def addFiles(): Unit = {
addFileToProject(packageName + "/Test1.scala",
"""
... |
Explain and rewrite the following Scala code: | package mesosphere.marathon.core.flow.impl
import akka.actor.ActorSystem
import akka.testkit.TestActorRef
import mesosphere.marathon.core.flow.LaunchTokenConfig
import mesosphere.marathon.core.matcher.manager.OfferMatcherManager
import mesosphere.marathon.core.task.bus.TaskChangeObservables.TaskChanged
import mesosphe... |
Explain and rewrite the following Scala code: | import org.scalatest.Spec
import org.scalatest.Matchers._
import spray.json._
import DefaultJsonProtocol._
import scala.collection.immutable.Map
/**
* Created by andi on 23.01.14.
*/
class JSonTest extends Spec {
object `Basic spray-json usage` {
val str =
"""
|{"Build": {
| "name":... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.