instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
/* * Copyright (C) 2012 The Regents of The University California. * All rights reserved. * * 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/LICENS...
Explain and rewrite the following Scala code:
package io.cronit.utils import akka.http.scaladsl.model.HttpMethods import io.cronit.utils.HttpMethodUtils.HttpMethodConverter import org.scalatest.{FlatSpec, Matchers} class HttpMethodUtilsTest extends FlatSpec with Matchers { it should "convert http method string to akka http method type" in { "GET".toHttpMe...
Explain and rewrite the following Scala code:
package sigmastate.serialization import sigmastate.Values.BigIntConstant import sigmastate._ class ModQSerializerSpecification extends SerializationSpecification { // TODO https://github.com/ScorexFoundation/sigmastate-interpreter/issues/327 ignore("ModQ: Serializer round trip") { forAll(bigIntConstGen) { x:...
Explain and rewrite the following Scala code:
package reactivemongo.core.protocol import scala.util.{ Success, Try } import scala.util.control.NonFatal import reactivemongo.io.netty.buffer.{ ByteBuf, Unpooled } import reactivemongo.io.netty.channel.ChannelId import reactivemongo.core.netty.BufferSequence import reactivemongo.core.protocol.buffer.ChannelBuffer...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala package testingSupport.test import com.intellij.execution.configurations.{RunConfiguration, ConfigurationFactory, ConfigurationType} import config.ScalaFacet /** * User: Alexander Podkhalyuzin * Date: 03.05.2009 */ abstract class AbstractTestRunConfigurationFactory(val typez: C...
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:
package com.sksamuel.elastic4s.analyzers import com.sksamuel.elastic4s.testkit.ElasticSugar import org.scalatest.{FreeSpec, Matchers} class NormalizerTest extends FreeSpec with Matchers with ElasticSugar { client.execute { createIndex("normalizer").mappings { mapping("test") fields ( keywordField...
Explain and rewrite the following Scala code:
/* * Happy Melly Teller * Copyright (C) 2013 - 2015, Happy Melly http://www.happymelly.com * * This file is part of the Happy Melly Teller. * * Happy Melly Teller 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 Fo...
Explain and rewrite the following Scala code:
package com.wavesplatform.transaction import scala.util.control.NoStackTrace sealed trait TxParseError extends NoStackTrace case class PBParsingError(underlying: Throwable) extends TxParseError { override val getMessage: String = s"Error while parsing protobuf transaction: ${underlying.getMessage}" } case class U...
Explain and rewrite the following Scala code:
package SMART import Chisel._ class MatrixArbiter4 extends Module { val io = new Bundle { val enable = UInt(width = 1, dir = INPUT) val requests = UInt(width = 4, dir = INPUT) val grants = UInt(width = 4, dir = OUTPUT) } val requests = io.requests.toBools val grants = Vec.fill(4){ Bool...
Explain and rewrite the following Scala code:
package demo3 import akka.actor.ActorSystem import akka.stream.ActorMaterializer import akka.stream._ import akka.stream.scaladsl._ import scala.concurrent.duration._ import akka.stream.scaladsl.FlowGraph.Implicits._ import FlowGraph.Implicits._ import scala.concurrent.Future import scala.concurrent.Await object Ex2 ...
Explain and rewrite the following Scala code:
/* * Copyright 2015 David R. Bild * * 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 sbox import scala.annotation.tailrec /* * Knight's Tour problem * "How can a knight jump on an N x N chessboard in such a way that it visits every square exactly once?" * * Hints: * - Represent the squares by pairs of their coordinates of the form (X, Y), where both X and Y are integers between 1 and 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:
/** * 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) 2009-2011 Mathias Doenitz * * 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.cterm2.mcfm1710.interops.smartcursor import com.asaskevich.smartcursor.api.{ModuleConnector, IBlockProcessor} import cpw.mods.fml.common.{Mod, Loader} import cpw.mods.fml.common.event._ import cpw.mods.fml.common.network.{NetworkRegistry, ByteBufUtils} import cpw.mods.fml.common.network.simpleimpl.{IMessag...
Explain and rewrite the following Scala code:
package orz.mongo.tochka import sbt._ import sbt.Keys._ import scala.xml._ import java.io._ import javax.xml.transform._ import javax.xml.transform.stream._ import orz.mongo.tochka.schemagen.model._ object SchemaGenaratorPlugin extends AutoPlugin { lazy val schemaConf = settingKey[String]("schema config xml")...
Explain and rewrite the following Scala code:
/* * Copyright 2016 rdbc contributors * * 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:
/* * Licensed to Elasticsearch under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this fi...
Explain and rewrite the following Scala code:
package japgolly.scalajs.benchmark.gui import japgolly.scalajs.benchmark.gui.CssSettings._ import japgolly.univeq.UnivEq object Styles extends StyleSheet.Inline { import dsl._ val enabled = Domain.boolean.map(Enabled.when) val validity = Domain.boolean.map(Valid.when) // val cssReset = style(scalacss.ext.Css...
Explain and rewrite the following Scala code:
package org.ausdigital.apecconnect.db.services import slick.dbio.DBIO import org.ausdigital.apecconnect.db.DbioOps._ import org.ausdigital.apecconnect.db.dao.BaseDao import org.ausdigital.apecconnect.db.model.{ HasMetaData, Identifiable, Record, RecordId } import scala.concurrent.{ ExecutionContext, Future } import...
Explain and rewrite the following Scala code:
/* * Copyright 2001-2009 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:
/* * 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 2014 Pellucid Analytics * * Licensed under the Apache License, Version 2.0 (the "License"); *...
Explain and rewrite the following Scala code:
package gapt.expr import gapt.expr.formula.All import gapt.expr.formula.And import gapt.expr.formula.Bottom import gapt.expr.formula.Ex import gapt.expr.formula.Top import gapt.expr.formula.constants.AndC import gapt.expr.formula.constants.ForallC import gapt.expr.formula.constants.LogicalConstant import gapt.expr.for...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
Explain and rewrite the following Scala code:
package com.olivergg /** * A trait that indicates that a scala object is compilable to HTML (using scalatags). */ trait HtmlCompilable { var optMode: String = _ var moduleName: String = _ /** * A method to override to indicate that the optMode will be used */ def useOptMode : Boolean = false /** *...
Explain and rewrite the following Scala code:
package scorex.transaction.state.database import org.h2.mvstore.MVStore import scorex.consensus.ConsensusModule import scorex.settings.Settings import scorex.transaction.state.database.blockchain.{StoredBlockSeq, StoredBlockTree, StoredBlockchain, StoredState} import scorex.transaction._ class BlockStorageImpl(settin...
Explain and rewrite the following Scala code:
package com.blinkbox.books.catalogue.searchv1 import com.blinkbox.books.spray.Page import com.blinkbox.books.spray.v1.Link import org.scalatest.{Matchers, FlatSpec} import spray.http.Uri class PageLinkerSpecs extends FlatSpec with Matchers { val uri = Uri("http://somehost.com/resource?param=foo&otherParam=bar&coun...
Explain and rewrite the following Scala code:
package spire package benchmark.jmh import org.openjdk.jmh.annotations._ import spire.math.Complex @State(Scope.Thread) class ComplexState extends StateSupport { var values: Array[Complex[Double]] = _ @Setup def setup(): Unit = values = init(size)(nextComplex) }
Explain and rewrite the following Scala code:
package net.bmjames.json import scalaz.Scalaz._ import scalaz.{MonadState, MonadPlus, StateT} /** Represents a transition, which may succeed or fail, from a cursor, to an updated cursor * together with a value: JCursor => Option[(JCursor, A)] * * Generally, movement commands return the new focus as the value, f...
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 epic.logo case class MinibatchInput[T, W](instance : DualVariableHolder[T, W], instanceNum : Int) case class MinibatchOutput[T, W, OracleS, MaxerS]( instance: DualVariableHolder[T, W], instanceNum: Int, df: W, loss: Double, oracleState: OracleS, maxerState: MaxerS)
Explain and rewrite the following Scala code:
#!/bin/sh L=`pwd` cp=`echo $L/lib/*` exec scala -cp "$cp" "$0" "$@" !# /* * Copyright 2015 MongoDB, 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/li...
Explain and rewrite the following Scala code:
package com.twitter.finatra.http.integration.tweetexample.test import com.twitter.finagle.http.Status import com.twitter.finatra.http.integration.tweetexample.main.TweetsEndpointServer import com.twitter.finatra.http.test.EmbeddedHttpServer import com.twitter.inject.Test import com.twitter.util.{Await, Future, FutureP...
Explain and rewrite the following Scala code:
package wom.types import spray.json.JsString import wom.values.{WomFile, WomPrimitive, WomString} import scala.util.{Success, Try} case object WomStringType extends WomPrimitiveType { val toDisplayString: String = "String" override protected def coercion = { case s: String => WomString(s) case s: JsStri...
Explain and rewrite the following Scala code:
package com.aurelpaulovic.scala_kata.s_99 /* * (*) Find the last element of a list * * scala> last(List(1, 1, 2, 3, 5, 8)) * Int = 8 * * (from: http://aperiodic.net/phil/scala/s-99/) */ import scala.annotation.tailrec import scala.util.control.TailCalls._ package object p01 { /** * Returns the last eleme...
Explain and rewrite the following Scala code:
package fastparsers.framework.parseresult /** * Extractor for ParseResult in case of success */ object Success { def unapply[T,U](p: ParseResult[T,U]) = if (p.success) Some(p.result) else None }
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:
package memcached import memcached.netty.messages.{StatusResponse, GetResponse} import scala.concurrent.Future object Client { def apply( host: String = "localhost", port: Int = 11211 ) : Client = new NettyClient(host, port) } trait Client { def set(key: String, bytes: Array[Byte], flags: Int = 0, expirati...
Explain and rewrite the following Scala code:
import filters.NoCacheFilter import javax.inject.{Inject, Singleton} import play.api.Environment import play.api.http.HttpFilters import play.api.mvc.EssentialFilter import play.filters.headers.{SecurityHeadersConfig, SecurityHeadersFilter} @Singleton class Filters @Inject()(env: Environment, n...
Explain and rewrite the following Scala code:
package dotty.tools package dotc package typer import core._ import ast._ import Trees._ import Constants._ import StdNames._ import Scopes._ import Denotations._ import ProtoTypes._ import Contexts._ import Symbols._ import Types._ import SymDenotations._ import Annotations._ import Names._ import NameOps._ import Fl...
Explain and rewrite the following Scala code:
package chat.tox.antox.fragments import android.content.{Intent, SharedPreferences} import android.os.Bundle import android.preference.PreferenceManager import android.support.v4.app.Fragment import android.view.View.OnClickListener import android.view.{LayoutInflater, View, ViewGroup} import android.widget.Button imp...
Explain and rewrite the following Scala code:
package scala.macros package trees private[macros] trait Trees extends Abstracts with Companions with Extensions { self: Universe => type Tree >: Null <: AnyRef // Tree.pos, Tree.syntax, Tree.structure type Ref >: Null <: Tree type Stat >: Null <: Tree type Name >: Null <: Ref // Name.value val Name: Name...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2016-2019 Lightbend Inc. <https://www.lightbend.com> */ package com.lightbend.lagom.javadsl.persistence.cassandra import java.util.concurrent.{ CompletableFuture, CompletionStage } import java.util.function.BiFunction import java.util.{ Collections, Optional, UUID, List => JList } import com.dat...
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 definiti.core.plugin.serialization import definiti.core.Configuration import spray.json._ private[core] class JsonSerialization(val config: Configuration) extends GeneratorSerialization with LibrarySerialization with RootJsonSerialization with ValidationJsonSerialization { def sealedTraitForm...
Explain and rewrite the following Scala code:
package nineclue.md2blogger import uk.co.bigbeeconsultants.http._ import java.net.URL import java.nio.file.{Path, Paths, Files, LinkOption} import scala.pickling._ import json._ import play.api.libs.json.{Json, JsObject, JsNumber, JsArray, JsString, JsValue} object MiniParser { val stringJson = new scala.util.matchi...
Explain and rewrite the following Scala code:
package zooowner package mocking import org.apache.zookeeper.AsyncCallback._ import org.apache.zookeeper.CreateMode._ import org.apache.zookeeper.KeeperException._ import org.apache.zookeeper.KeeperException.Code import org.apache.zookeeper.{Watcher, WatchedEvent} import org.apache.zookeeper.Watcher.Event.{EventType, ...
Explain and rewrite the following Scala code:
package dotty.tools package dotc package ast import core._ import Flags._, Trees._, Types._, Contexts._ import Names._, StdNames._, NameOps._, Decorators._, Symbols._ import util.HashSet trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => import TreeInfo._ // Note: the <: Type constraint looks nece...
Explain and rewrite the following Scala code:
package com.lookout.borderpatrol.sessionx import java.util.concurrent.TimeUnit import com.lookout.borderpatrol.crypto.Generator import com.lookout.borderpatrol.util.Combinators.tap import com.twitter.bijection.Injection import com.twitter.finagle.httpx.{Response, Request, Cookie} import com.twitter.util._ import scal...
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 avrohugger package tool /** Command-line driver.*/ object Main { def main(args: Array[String]) = { val r = new Runner(System.in, System.out, System.err) val exitCode = r.run(args) System.exit(exitCode) } }
Explain and rewrite the following Scala code:
package fly.play.s3 import java.io.File import java.lang.IllegalArgumentException import java.net.URLEncoder import java.util.Date import scala.concurrent.Await import scala.concurrent.Awaitable import scala.concurrent.Future import scala.concurrent.duration.Duration import scala.concurrent.duration.DurationInt impor...
Explain and rewrite the following Scala code:
/** * Licensed to the Minutemen Group under one or more contributor license * agreements. See the COPYRIGHT file distributed with this work for * additional information regarding copyright ownership. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in complian...
Explain and rewrite the following Scala code:
/* * Copyright 2015 Dennis Vriend * * 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 name.mikulskibartosz.parkinglot.clock import java.time.{ZoneId, ZonedDateTime} import org.scalatest.{FlatSpec, Matchers} import scala.util.{Failure, Success} class CalculateElapsedHoursSpec extends FlatSpec with Matchers{ val currentTime = ZonedDateTime.of(2016, 11, 1, 12, 0, 0, 0, ZoneId.of("UTC")) val...
Explain and rewrite the following Scala code:
package org.bitcoins.core.protocol.transaction import org.bitcoins.core.currency.{CurrencyUnit, CurrencyUnits, Satoshis} import org.bitcoins.core.number.UInt32 import org.bitcoins.core.policy.Policy import org.bitcoins.core.protocol.script._ import org.bitcoins.core.script.control.OP_RETURN import org.bitcoins.core.sc...
Explain and rewrite the following Scala code:
package domino.test import java.util.HashMap import java.util.ServiceLoader import de.kalpatec.pojosr.framework.launch.PojoServiceRegistry import de.kalpatec.pojosr.framework.launch.PojoServiceRegistryFactory import org.osgi.framework.BundleActivator import de.kalpatec.pojosr.framework.PojoSR trait PojoSrTestHelper {...
Explain and rewrite the following Scala code:
package controller import _root_.controller._ import _root_.model._ import org.joda.time.LocalDate import org.scalatra.test.scalatest._ import skinny.test._ import org.scalatest.{ Matchers, FunSpec } import skinny.DBSettings class AssignmentsControllerSpec extends FunSpec with Matchers with DBSettings { def create...
Explain and rewrite the following Scala code:
import com.typesafe.sbt.GitPlugin import com.typesafe.sbt.GitPlugin.autoImport._ import de.heikoseeberger.sbtheader.HeaderPlugin import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._ import de.heikoseeberger.sbtheader.HeaderPattern import de.heikoseeberger.sbtheader.license._ import sbt._ import sbt.Keys._ impor...
Explain and rewrite the following Scala code:
package at.logic.gapt.proofs.ceres import at.logic.gapt.proofs._ import at.logic.gapt.proofs.lk._ import at.logic.gapt.expr._ import at.logic.gapt.utils.Logger /** * Algorithms extracting structs from LK proofs, preparing them for gui code etc. */ /** * Returns s.toString with color coding of struct operators. Wh...
Explain and rewrite the following Scala code:
/** * Class AccentFoldingArrayAdapter. * * @author Yujian Zhang <yujian{dot}zhang[at]gmail(dot)com> * * License: * GNU General Public License v2 * http://www.gnu.org/licenses/gpl-2.0.html * Copyright (C) 2013-2015 Yujian Zhang */ package net.whily.android.worldmetro import java.text.Normalizer import an...
Explain and rewrite the following Scala code:
package skutek.abstraction.internals import skutek.abstraction.{!!, HandlerStub} import skutek.abstraction.ComputationCases.{Operation => AbstractOp} import skutek.abstraction.effect.{EffectId, AnyEffect, Effect} trait PrimitiveHandler extends HandlerStub { private[abstraction] val effectId: EffectId type ThisEf...
Explain and rewrite the following Scala code:
package aecor.kafkadistributedprocessing.internal import java.util import aecor.data.Committable import cats.effect.concurrent.Deferred import cats.effect.implicits._ import cats.effect.{ ConcurrentEffect, Effect } import cats.implicits._ import fs2.Stream import fs2.concurrent.Queue import org.apache.kafka.clients.c...
Explain and rewrite the following Scala code:
package ca.yvrsfo.tripshistory import org.scalatest._ import scala.util.parsing.json.{JSON, JSONArray, JSONObject} class CitySpec extends FlatSpec with Matchers { "City" should ".name" in { Nowhere.name should be ("Nowhere") } it should ".latlong" in { Nowhere.latlong should be (0.0, 0.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 gitbucket.core.controller import java.io.File import javax.servlet.http.{HttpServletRequest, HttpServletResponse} import gitbucket.core.plugin.PluginRegistry import gitbucket.core.repo.html import gitbucket.core.helper import gitbucket.core.service._ import gitbucket.core.util._ import gitbucket.core.util.JGi...
Explain and rewrite the following Scala code:
package se.gigurra.wallace.gamemodel trait TerrainStoring[T_TerrainStorage] { def width(t: T_TerrainStorage): Long def height(t: T_TerrainStorage): Long def get(t: T_TerrainStorage, iPatch: Long): TerrainPatch def set(t: T_TerrainStorage, iPatch: Long, patch: TerrainPatch): Unit } trait TerrainStorageFactory[...
Explain and rewrite the following Scala code:
/* * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agr...
Explain and rewrite the following Scala code:
/* * Copyright 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 2010 Maxime Lévesque * * 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://ww...
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:
import tw.com.ehanlin.mde.MongoEmbedder class Example5 extends ReadmeExampleTest {def is = s2""" Example5 $example5 """ def example5 = { val dsl = """ |@find <db=info coll=postal_code projection={ name : 1 }> |[ | @count (db=user coll=user query={ height : { $gte : 200 } , post...
Explain and rewrite the following Scala code:
import com.tngtech.jgiven.annotation._ import com.tngtech.jgiven._ class GivenStage extends Stage[GivenStage] { @ProvidedScenarioState var someInt = 0 @ProvidedScenarioState var anotherInt = 0 def some_value(a:Int) = { someInt = a this } def another_value(b:Int) = { anotherInt = b ...
Explain and rewrite the following Scala code:
package io.github.shogowada.scalajs.reactjs.redux import io.github.shogowada.scalajs.reactjs.React import io.github.shogowada.scalajs.reactjs.React.Render import io.github.shogowada.scalajs.reactjs.classes.ReactClass import scala.scalajs.js class ContainerComponentFactory[WrappedProps](nativeFactory: js.Function1[js...
Explain and rewrite the following Scala code:
package com.yahoo.scalops.dsl.actions /* * Copyright (c) 2012 Yahoo! Inc. All rights reserved. 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 Un...
Explain and rewrite the following Scala code:
package de.unifreiburg.cs.proglang.jgs.constraints import de.unifreiburg.cs.proglang.jgs.constraints.TypeViews.TypeView final case class Constraint[Level] (val kind: ConstraintKind, private val lhs: CTypes.CType[Level], private val rhs: CTypes.CType[Level] ) { def isSatisfied(types: TypeDomain[Level], a: Assig...
Explain and rewrite the following Scala code:
package dhg.ccg.tag.learn import org.junit.Test import dhg.util._ import org.junit.Assert._ import dhg.ccg.tag.learn._ import dhg.ccg.prob._ import dhg.ccg.tag._ import org.apache.commons.math3.random.{ MersenneTwister, RandomGenerator } import dhg.ccg.test.TestUtil.MockableRandomGenerator import dhg.ccg.tagdict.TagDi...
Explain and rewrite the following Scala code:
/* * Copyright (C) FuseSource, Inc. * http://fusesource.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 by ...
Explain and rewrite the following Scala code:
package fpinscala.laziness import Stream._ trait Stream[+A] { def foldRight[B](z: => B)(f: (A, => B) => B): B = // The arrow `=>` in front of the argument type `B` means that the function `f` takes its second argument by name and may choose not to evaluate it. this match { case Cons(h, t) => f(h(), t().f...
Explain and rewrite the following Scala code:
package com.virdis.cleanup import com.virdis.cleanup.Constants._ import org.apache.spark.sql.types.{StringType, StructField, StructType} import org.apache.spark.sql.{SaveMode, Row, SQLContext, DataFrame} /** * Created by sandeep on 2/2/16. */ trait ProjectComment { self: CommonDataFunctions => def extractCo...
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:
import org.parboiled2._ case class Check(comp: (Double, Double) => Boolean, w: Double, c: Double, errorLevel: Int) class ThresholdParser(val input: ParserInput) extends Parser { def Digits = rule { oneOrMore( (CharPredicate.Digit | '.') ) } def Number = rule { capture(Digits) ~> (_.toDouble) } def Values = rule...
Explain and rewrite the following Scala code:
trait coll[m[+x]] trait coll2[m[-x]] trait coll3[m[x]] trait coll4[m[x <: y], y] class FooInvar[x] class FooContra[-x] class FooCov[+x] class FooString[+x <: String] object fcollok extends coll[FooCov] object fcollinv extends coll[FooInvar] // error object fcollcon extends coll[FooContra] // error object ...
Explain and rewrite the following Scala code:
package sorted import org.scalatest.FunSuite class ModelTest extends FunSuite { test("model0") { val model = new MockModel0 assert(42 === model.data()) } test("model1_A") { checkModel1Single("A", 1) } test("model1_B") { checkModel1Single("B", 2) } test("model1_C") { checkModel1Si...
Explain and rewrite the following Scala code:
package com.stefansavev.randomprojections.examples import com.stefansavev.randomprojections.datarepr.dense._ import com.stefansavev.randomprojections.file.{CSVFile, CSVFileOptions} import com.stefansavev.randomprojections.implementation.indexing.IndexBuilder import com.stefansavev.randomprojections.implementation._ 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"); yo...
Explain and rewrite the following Scala code:
/*** * Copyright 2016 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:
package org.purview.core.report import java.io.Serializable import org.purview.core.data.Color import org.purview.core.data.Matrix import org.purview.core.data.plot.PlotEntry import org.purview.core.data.shape.ShapeCommand sealed abstract class ReportEntry extends NotNull with Serializable { val level: ReportLevel ...
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:
object K { implicit final class RichIterable[A](val it: Iterable[A]) extends AnyVal { def mean(implicit num: Fractional[A]): A = { var sum = num.zero var size = num.zero val one = num.one import num.mkNumericOps it.foreach { e => /*start*/sum.+(e)/*end*/ sum += ...
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 mesosphere.mesos import com.typesafe.scalalogging.StrictLogging import mesosphere.marathon._ import mesosphere.marathon.api.serialization.ContainerSerializer import mesosphere.marathon.core.health.MesosHealthCheck import mesosphere.marathon.core.task import mesosphere.marathon.core.task.Task import mesosphere....
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
Explain and rewrite the following Scala code:
package com.twitter.finagle.http.exp import com.twitter.conversions.StorageUnitOps._ import com.twitter.io.Buf import com.twitter.util.StorageUnit import java.io.File /** * Provides a convenient interface for querying the content of the `multipart/form-data` body. * * To decode the non-chunked, POST request into a...