instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
Explain and rewrite the following Scala code: | /*
* Copyright 2020 Precog Data
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to ... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | package com.github.gabadi.scalajooq
import db.test.public.Tables.USER
import db.test.public.tables
import db.test.public.tables.records.UserRecord
import org.jooq.DSLContext
class JooqDAOTest extends BaseSpec {
implicit val userMeta = JooqMeta.metaOf[tables.User, UserRecord, User]
lazy val userDAO = new DefaultJ... |
Explain and rewrite the following Scala code: | import sbt._
import Keys._
object UpdatableBuild extends Build{
var root = Project(id = "UPDATABLE",
base = file("."))
val projectVersion = SettingKey[(String,Publication)]("projectVersion", "Project version for this building.")
def revision : String = {
import java.util.Ca... |
Explain and rewrite the following Scala code: | package at.forsyte.apalache.tla.assignments
import at.forsyte.apalache.tla.lir.oper.TlaBoolOper
import at.forsyte.apalache.tla.lir.{LetInEx, OperEx, TlaEx, TlaOperDecl}
import at.forsyte.apalache.tla.lir.transformations.{TlaExTransformation, TransformationTracker}
/**
* `Reordering` allows us to change the order of... |
Explain and rewrite the following Scala code: | package com.atanana.parsers
import com.atanana.data.Editor
import net.ruippeixotog.scalascraper.browser.JsoupBrowser
import net.ruippeixotog.scalascraper.dsl.DSL.Extract._
import net.ruippeixotog.scalascraper.dsl.DSL._
import net.ruippeixotog.scalascraper.model.Element
class TournamentPageParser {
def getEditors(ht... |
Explain and rewrite the following Scala code: | /*
* (c) Copyright 2016 Hewlett Packard Enterprise Development LP
*
* 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 b... |
Explain and rewrite the following Scala code: | /*
* Copyright 2015 Heiko Seeberger
*
* 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: | /*
* 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 com.themillhousegroup.arallon
import org.specs2.mutable.Specification
import org.joda.time.DateTime
import com.typesafe.scalalogging.LazyLogging
import com.themillhousegroup.arallon.zones._
class TimeInZoneInstanceSpec extends Specification with LazyLogging {
"Strongly-typed time instances" should {
"... |
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2010 Orbeon, Inc.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation; either version
* 2.1 of the License, or (at your option) any later version.
*
* This program i... |
Explain and rewrite the following Scala code: | /*
* Copyright © 2015 Lukas Rosenthaler, Benjamin Geer, Ivan Subotic,
* Tobias Schweizer, André Kilchenmann, and Sepideh Alassi.
*
* This file is part of Knora.
*
* Knora is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the F... |
Explain and rewrite the following Scala code: | package nexus
import nexus.diff.syntax._
import nexus.diff._
/**
* '''Nexus''': Typeful & typesafe deep learning.
* @author Tongfei Chen
*/
package object diff {
val _0 = shapeless.nat._0
val _1 = shapeless.nat._1
val _2 = shapeless.nat._2
val _3 = shapeless.nat._3
val _4 = shapeless.nat._4
val _5 = s... |
Explain and rewrite the following Scala code: | package lazybenchmarks
import leon.lazyeval._
import leon.lang._
import leon.annotation._
import leon.instrumentation._
//import leon.invariant._
object Sorting {
// TODO: making this parametric will break many things. Fix them (note: we need each instantiation to be a unique closure)
sealed abstract class LList ... |
Explain and rewrite the following Scala code: | /* __ __ *\\
* / /____ ___ ____ ___ ___ _/ / lasius *
* / __/ -_) _ `/ _ \\/ _ \\/ _ `/ / contributed by tegonal *
* \\__/\\__/\\_, /\\___/_//_/\\_,_/_/ http://tegonal.com/ *
... |
Explain and rewrite the following Scala code: | package scalaxy.compilets
package plugin
import pluginBase._
import components._
import scala.tools.nsc.Global
import scala.tools.nsc.plugins.PluginComponent
import scala.tools.nsc.transform.{Transform, TypingTransformers}
import scala.tools.nsc.typechecker.Analyzer
import scala.tools.nsc.typechecker.Contexts
import ... |
Explain and rewrite the following Scala code: | package scala.quoted
package util
trait ConstructExpr[T] {
type Elems <: Tuple
def from(x: Elems)(using Quotes): Expr[T]
// def from(x: Tuple.Map[Elems, Expr])(using Quotes): Expr[T] // alternative
}
object ConstructExpr {
def apply[T](using ce: ConstructExpr[T]): ce.type = ce
/** Default implementat... |
Explain and rewrite the following Scala code: | package mesosphere.marathon
package core.storage.store.impl
import org.apache.curator.framework.CuratorFramework
import scala.language.implicitConversions
package object zk {
implicit def toRichCurator(client: CuratorFramework): RichCuratorFramework = new RichCuratorFramework(client)
}
|
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala
package project.converter
import com.intellij.conversion.{ConversionContext, ConverterProvider}
/**
* @author Pavel Fatin
*/
class ScalaProjectConverterProvider extends ConverterProvider("scala-facets-to-sdks") {
def getConversionDescription = "Scala facets will be converted to... |
Explain and rewrite the following Scala code: | package mr.merc.economics
import mr.merc.economics.Culture.LatinHuman
import mr.merc.economics.PopulationType.{Aristocrats, Farmers}
import mr.merc.politics.{Party, PoliticalViews, Province, State}
import org.mockito.MockitoSugar
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
... |
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: | /*
* Copyright (c) 2015-2017 Toby Weston
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or a... |
Explain and rewrite the following Scala code: | package com.twitter.finagle.service
import com.twitter.finagle.Service
import com.twitter.util.{Await, Future, Promise, Return}
import org.mockito.Matchers
import org.specs.SpecificationWithJUnit
import org.specs.mock.Mockito
class RefcountedServiceSpec extends SpecificationWithJUnit with Mockito {
"PoolServiceWrap... |
Explain and rewrite the following Scala code: | /*
* Copyright 2015 LG CNS.
*
* 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 edu.umass.cs.automan.tools
import java.io.{ObjectOutputStream, FileOutputStream}
import edu.umass.cs.automan.core.policy.aggregation.{PrecompTable, AdversarialPolicy}
object PrecomputeNumToRun extends App {
val output_filename = "PossibilitiesTable.dat"
val num_possibilities = 1000
val num_rewards = 25
... |
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 Tomer Gabel
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 writi... |
Explain and rewrite the following Scala code: | package it.almawave.daf.standardization.refactoring
import it.almawave.kb.http.models.Hierarchy
import scala.collection.mutable.ListBuffer
// TODO: rewrite as JUnit
object CheckReducepath extends App {
val e_A = StdHierarchy("http://elements/A", List("http://elements/A"))
val e_A1 = StdHierarchy("http://elements... |
Explain and rewrite the following Scala code: | import com.cave.metrics.data.Role
import data.UserData
import org.joda.time.DateTime
import org.mockito.Matchers._
import org.mockito.{Matchers, Mockito}
import scala.concurrent.{Future, ExecutionContext}
import scala.util.{Failure, Success}
import org.mockito.Mockito._
import play.api.mvc.Results
import play.api.tes... |
Explain and rewrite the following Scala code: | import com.google.gson.Gson
import java.io._
object Books extends App {
case class Book(id:String, language:String, edition:String, author:String)
case class Library(books:Array[Book])
val gson = new Gson
val inFile = io.Source.fromFile("./library.json")
val outFile = new PrintWriter(new File("./out... |
Explain and rewrite the following Scala code: | package com.monovore.coast
import com.monovore.coast.wire.{BinaryFormat, Partitioner}
package object flow {
type AnyStream[A, +B] = StreamDef[AnyGrouping, A, B]
type GroupedStream[A, +B] = StreamDef[Grouped, A, B]
type AnyPool[A, +B] = PoolDef[AnyGrouping, A, B]
type GroupedPool[A, +B] = PoolDef[Grouped, A,... |
Explain and rewrite the following Scala code: | package gitbucket.core.plugin
import java.io.{File, FilenameFilter, InputStream}
import java.net.URLClassLoader
import javax.servlet.ServletContext
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
import gitbucket.core.controller.{Context, ControllerBase}
import gitbucket.core.service.ProtectedBran... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala.debugger.renderers
import java.util
import com.intellij.debugger.engine.evaluation.{EvaluateException, EvaluationContextImpl}
import com.intellij.debugger.settings.NodeRendererSettings
import com.intellij.debugger.ui.impl.ThreadsDebuggerTree
import com.intellij.debugger.ui.impl.wat... |
Explain and rewrite the following Scala code: | package com.wordtrellis.projecteuler
/**
* Problem 31
*
* In England the currency is made up of pound, £, and pence, p, and
* there are eight coins in general circulation:
*
* 1p, 2p, 5p, 10p, 20p, 50p, 1 pound (100p) and 2 pound (200p).
*
* It is possible to make 2 pound in the following way:
... |
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) 2002-2012 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j 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 Foundati... |
Explain and rewrite the following Scala code: | package akka.duke.taskmanager.plugin
import java.lang.reflect.Method
import akka.duke.taskmanager.Task
import concurrent.duration._
import concurrent.ExecutionContext.Implicits.global
import scala.Some
import akka.actor.{ActorRef, ActorSystem}
import akka.duke.taskmanager.plugin.annotations.Run
class PluginWrapper(c... |
Explain and rewrite the following Scala code: | package nlpdata.structure
case class Word(index: Int, pos: String, token: String)
|
Explain and rewrite the following Scala code: | /*
* Copyright 2008 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
Explain and rewrite the following Scala code: | package com.ajjpj.adiagram.render.lineend
import javafx.scene.canvas.GraphicsContext
import javafx.scene.shape.{StrokeLineCap, StrokeLineJoin}
import com.ajjpj.adiagram.geometry.{Angle, LenUnit, Length, Vector2}
import com.ajjpj.adiagram.render.{LineStyle, Model2Screen}
class RoundPointedArrowLineEnd(arrowLengthFac... |
Explain and rewrite the following Scala code: | package controllers.util
import java.util.Locale
import play.api.i18n.{DefaultLangs,DefaultMessagesApi,Lang,Langs,Messages,MessagesApi}
/** MessagesApi whose methods should never be called.
*
* Used for dependency injection.
*/
object NullMessagesApi {
val lang: Lang = Lang(Locale.ROOT)
val langs: Langs = n... |
Explain and rewrite the following Scala code: | def extract[E, A]: Product[E, A] => A = {
case Product((e, a)) => a
} |
Explain and rewrite the following Scala code: | package frameless
import frameless.functions.aggregate._
import org.scalacheck.Prop
import org.scalacheck.Prop._
import org.scalatest.Matchers
class SchemaTests extends TypedDatasetSuite with Matchers {
def prop[A](dataset: TypedDataset[A]): Prop = {
TypedExpressionEncoder.targetStructType(dataset.encoder) ?= ... |
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 pl.newicom.eventstore
import akka.actor.ActorSystem
import akka.persistence.PersistentRepr
import akka.persistence.eventstore.snapshot.EventStoreSnapshotStore.SnapshotEvent
import akka.persistence.journal.Tagged
import akka.util.ByteString
import eventstore.{Content, ContentType, EventData}
import pl.newicom.d... |
Explain and rewrite the following Scala code: | import scala.collection.JavaConverters._
import com.amazonaws.services.{ dynamodbv2 => aws }
object Item {
def apply(table: Table, attributes: java.util.Map[String, aws.model.AttributeValue]): Item = new Item(
table = table,
attributes = attributes.asScala.toSeq.map { case (k, v) => Attribute(k, AttributeVal... |
Explain and rewrite the following Scala code: | class Par[S]
val p = new Par[String]
class Foo[T[x]<:Par[x]](t: T[String])
new Foo[p.type](p) // crashes compiler
|
Explain and rewrite the following Scala code: | import java.io.IOException
import java.nio.file._
import java.nio.file.attribute.BasicFileAttributes
import Scalatic.stringFromFile
import ScalaticSuite._
import org.scalatest._
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.time.{Seconds, Span}
class ScalaticSuite extends FunSuite with BeforeAndAf... |
Explain and rewrite the following Scala code: | /*
* Copyright 2009-2016 DigitalGlobe, 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 ag... |
Explain and rewrite the following Scala code: | package tetris.tetrominoes
import tetris.Stack.{Square, height, width}
/**
* Created by papacharlie on 10/17/15.
*/
abstract class Tetromino {
def x: Int
def rotation: Int
if (x < 0 || x > width) {
throw new IllegalArgumentException("Piece is out of board bounds! (%d)".format(x))
}
def rotate: Tet... |
Explain and rewrite the following Scala code: | package com.overviewdocs.background.filegroupcleanup
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import com.overviewdocs.database.HasDatabase
import com.overviewdocs.models.tables.GroupedFileUploads
/**
* Delete [[GroupedFileUpload]]s and their contents.
*/
trait Group... |
Explain and rewrite the following Scala code: | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.cosmos.spark
import com.azure.cosmos.spark.CosmosPredicates.assertOnSparkDriver
import com.azure.cosmos.spark.diagnostics.BasicLoggingTrait
import org.apache.spark.sql.SparkSession
import org.apache.spark.... |
Explain and rewrite the following Scala code: | package de.hyronx.matter.compiler.generators
import cafebabe._
import cafebabe.ByteCodes._
import cafebabe.AbstractByteCodes._
import de.hyronx.matter.Config
import de.hyronx.matter.compiler.types.{TypeTrait, UserTypeTrait, VariableLike}
class ClassGenerator(typ: UserTypeTrait)(implicit config: Config, pkg: PackageM... |
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 com.twitter.finagle.exp.mysql
import com.twitter.finagle.ServiceFactory
import com.twitter.finagle.stats.{NullStatsReceiver, StatsReceiver}
import com.twitter.util.{Closable, Future, Time}
import java.util.logging.Level
object Client {
/**
* Creates a new Client based on a ServiceFactory.
*/
def app... |
Explain and rewrite the following Scala code: | package com.twitter.finagle.redis
import _root_.java.lang.{Long => JLong}
import com.twitter.finagle.redis.protocol._
import com.twitter.finagle.redis.protocol.commands._
import com.twitter.util.Future
import org.jboss.netty.buffer.ChannelBuffer
import util.ReplyFormat
trait BtreeSortedSetCommands { self: BaseClient ... |
Explain and rewrite the following Scala code: | package nodes.util
import breeze.linalg.{DenseVector, argtopk}
import pipelines.Transformer
/**
* Transformer that returns the indices of the largest k values of the vector, in order
*/
class TopKClassifier(k: Int) extends Transformer[DenseVector[Double], Array[Int]] {
override def apply(in: DenseVector[Double]):... |
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: | package edu.mit.csail.sdg.ormolu.form
import edu.mit.csail.sdg.hsqldb.syntax.value
/**
* A Formula in Ormolu that is known to evaluate to false
*/
case object False extends Formula {
override val boolExpr = value.False
} |
Explain and rewrite the following Scala code: | /* ___ ____ ___ __ ___ ___
** / _// __// _ | / / / _ | / _ \ Scala classfile decoder
** __\ \/ /__/ __ |/ /__/ __ |/ ___/ (c) 2003-2010, LAMP/EPFL
** /____/\___/_/ |_/____/_/ |_/_/ http://scala-lang.org/
**
*/
package scala.tools.scalap
package scalax
package rules
package scalasig
object... |
Explain and rewrite the following Scala code: | /*
* Copyright 2016 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or a... |
Explain and rewrite the following Scala code: | /*
* =========================================================================================
* Copyright © 2015 the khronus project <https://github.com/hotels-tech/khronus>
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You m... |
Explain and rewrite the following Scala code: | package at.fh.swengb.android_resifo
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.View
/**
* Created by Martin on 15.01.2017.
*/
class ErfolgreichActivity extends Activity{
override protected def onCreate(savedInstanceState: Bundle) {
super.onCreate(... |
Explain and rewrite the following Scala code: | /*
* Copyright 2009-2015 DigitalGlobe, 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 ag... |
Explain and rewrite the following Scala code: | package com.prealpha.pipe.document
import com.prealpha.pipe.math.{MathCompiler, ParseException}
import scala.util.Try
import scala.util.parsing.combinator.RegexParsers
private[document] object InlineParser extends RegexParsers {
def parse(input: String): Try[String] = {
if (input == "")
scala.util.Success... |
Explain and rewrite the following Scala code: | package base.job
import org.apache.spark.ml.Pipeline
import org.apache.spark.ml.classification.RandomForestClassifier
import org.apache.spark.ml.evaluation.MulticlassClassificationEvaluator
import org.apache.spark.ml.feature.{StringIndexer, VectorIndexer}
import org.apache.spark.ml.tuning.{CrossValidator, ParamGridBui... |
Explain and rewrite the following Scala code: | package com.caseystella.analysis
import org.apache.spark.scheduler.InputFormatInfo
import org.apache.spark.SparkContext
import org.apache.spark.deploy.SparkHadoopUtil
/**
* Created by cstella on 2/14/14.
*/
object Driver {
val usage =
"""
|Usage: command_analysis [--stop stop] input output
""... |
Explain and rewrite the following Scala code: | /*
Copyright (c) 2014, Marco Franzoni, Università di Bologna
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 source code must retain the above copyright notice, this list
of con... |
Explain and rewrite the following Scala code: | package org.allenai.pnp.semparse
import scala.collection.mutable.MultiMap
import com.jayantkrish.jklol.ccg.lambda.Type
import com.jayantkrish.jklol.ccg.lambda2.Expression2
import scala.collection.mutable.ListBuffer
case class EntityLinking(matches: List[(Span, Entity, List[Int], Double)]) {
val entities = matches.... |
Explain and rewrite the following Scala code: | package org.shapelogic.sc.polygon
import org.shapelogic.sc.util.MapOperations._
import java.awt.geom.Point2D
import org.shapelogic.sc.util.Constants
import scala.collection.mutable.HashMap
import scala.collection.mutable.Map
import scala.collection.mutable.HashSet
import scala.collection.mutable.Set
import org.shap... |
Explain and rewrite the following Scala code: | package opennlp.scalabha.tag.support
import scala.collection.{Map => CMap}
import opennlp.scalabha.util.CollectionUtils._
import opennlp.scalabha.util.CollectionUtil._
/**
* A builder for frequency distributions. Stores counts (in a mutable
* fashion) and allows counts to be added. A distribution based on the
*... |
Explain and rewrite the following Scala code: | package scalan.primitives
import scalan.{ScalanExp, ScalanStd, Scalan}
trait Exceptions { self: Scalan =>
def THROW(msg: Rep[String]): Rep[Unit]
}
trait ExceptionsStd extends Exceptions { self: ScalanStd =>
def THROW(msg: Rep[String]): Rep[Unit] = throw new Exception(msg)
}
trait ExceptionsExp extends Exception... |
Explain and rewrite the following Scala code: | package util
import javax.inject.Singleton
import com.google.inject.Inject
import org.reactivecouchbase.ReactiveCouchbaseDriver
import play.api.inject.ApplicationLifecycle
import scala.concurrent.Future
@Singleton
class CouchbaseBuckets @Inject()(lifecycle: ApplicationLifecycle) {
private val driver = ReactiveCo... |
Explain and rewrite the following Scala code: | package com.twitter.finagle.zipkin.thrift
import org.scalatest.mock.MockitoSugar
import org.scalatest.FunSuite
import com.twitter.finagle.tracing.{Annotation, Record, SpanId, TraceId}
import com.twitter.util.Time
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
@RunWith(classOf[JUnitRunner])
cla... |
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: | /*
* 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 controllers
import models._
import BidValue._
import Role._
trait Authorization {
def apply[A](implicit r: SlickRequest[A]): Boolean
}
object IsAuthor extends Authorization {
def apply[A](implicit r: SlickRequest[A]) = true
}
object IsPCMember extends Authorization {
def apply[A](implicit r: SlickRequ... |
Explain and rewrite the following Scala code: | package sparklyr
import java.util.HashMap
import java.util.concurrent.ConcurrentHashMap
import org.apache.spark.SparkContext
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.Column
import org.apache.spark.sql.DataFrame
import org.apache.spark.sql.Encoder
import org.apache.spark.sql.Encoders
import org.apac... |
Explain and rewrite the following Scala code: | // These are meant to be typed into the REPL. You can also run
// scala -Xnojline < repl-session.scala to run them all at once.
import scala.math._
val num = 3.14
val fun = ceil _
fun(num)
Array(3.14, 1.42, 2.0).map(fun)
|
Explain and rewrite the following Scala code: | /*
Spot is a bot, implementing a subset of AIML, and some extensions.
Copyright (C) 2016 Marius Feteanu
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 o... |
Explain and rewrite the following Scala code: |
package controllers
import play.api.mvc._
import play.api.mvc.Results._
import play.api.libs.json._
import play.api.libs.concurrent._
import play.api.libs.iteratee._
import play.api.libs.concurrent.Execution.Implicits._
import play.api.libs.iteratee.{Enumerator, Iteratee}
import scala.concurrent.Future
import actors... |
Explain and rewrite the following Scala code: | /*
* Copyright 2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable l... |
Explain and rewrite the following Scala code: | package enums
import play.api.libs.json._
import scala.slick.driver.MySQLDriver.simple._
/**
* 容器类型
*
* @author of546
*/
object ContainerTypeEnum extends Enumeration {
type Container = Value
val vm = Value("vm")
val docker = Value("docker")
implicit val enumMapper = MappedColumnType.base[Container, Strin... |
Explain and rewrite the following Scala code: | /*
* Copyright 2019 Spotify AB.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to ... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.cbt.project.settings
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings
class CbtExecutionSettings(val realProjectPath: String,
val isCbt: Boolean,
val useCbtForInternalTasks: Boolean,
... |
Explain and rewrite the following Scala code: | package de.unihamburg.vsis.sddf.test.reading.goldstandard
import org.apache.spark.rdd.RDD
import org.scalatest.FunSuite
import de.unihamburg.vsis.sddf.reading.Tuple
import de.unihamburg.vsis.sddf.reading.goldstandard.PipeReaderGoldstandardIdToTuple
import de.unihamburg.vsis.sddf.reading.goldstandard.PipeReaderGoldsta... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2014 - 2017 Contributors as noted in the AUTHORS.md file
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option)... |
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 ingraphation
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you... |
Explain and rewrite the following Scala code: | /*
* Copyright © 2015-2019 the contributors (see Contributors.md).
*
* This file is part of Knora.
*
* Knora is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
*... |
Explain and rewrite the following Scala code: | package tastytest
object TestChildren {
def test1 = new Child
def test2 = Module
}
|
Explain and rewrite the following Scala code: | package lila.base
import org.specs2.mutable.Specification
// import scalatags.Text.all._
import RawHtml._
class RawHtmlTest extends Specification {
val htmlTags = "<[^>]++>".r
def copyLinkConsistency(text: String) = {
// Plain text of linkified text should linkify to the same result.
val firstHtml = add... |
Explain and rewrite the following Scala code: | package com.example
import akka.actor.{Actor, ActorRef, ActorLogging, Props, ReceiveTimeout}
import akka.util.Timeout
import org.joda.time.DateTime
import org.joda.time.format.{ DateTimeFormatter, ISODateTimeFormat }
import org.json4s.jackson.Serialization
import org.json4s.{ CustomSerializer, DefaultFormats, Formats,... |
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: | /*
* Copyright (c) 2014-2021 by The Monix Project Developers.
* See the project homepage at: https://monix.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache... |
Explain and rewrite the following Scala code: | package example
import org.scalatest.FunSuite
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
/**
* This class implements a ScalaTest test suite for the methods in object
* `Lists` that need to be implemented as part of this assignment. A test
* suite is simply a collection of individual te... |
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) 2014-2018 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 com.github.mdr.mash.ns.http
import com.github.mdr.mash.classes.{ AbstractObjectWrapper, Field, MashClass, NewStaticMethod }
import com.github.mdr.mash.functions.{ BoundParams, MashMethod, Parameter, ParameterModel }
import com.github.mdr.mash.ns.core._
import com.github.mdr.mash.ns.json.ReadFunction.parseJson
... |
Explain and rewrite the following Scala code: | package com.packtpub
import com.sksamuel.elastic4s.ElasticDsl._
import com.sksamuel.elastic4s.{ElasticClient, ElasticsearchClientUri}
import com.sksamuel.elastic4s.indexes._
import org.elasticsearch.cluster.health.ClusterHealthStatus
trait ElasticSearchClientTrait {
val client:ElasticClient ={
val uri = Elastic... |
Explain and rewrite the following Scala code: | package gie
package object cp {
val NULLCP = -1
def from(data: String) = new StringToCPIterator(data)
class StringToCPIterator(data: String) extends Iterator[Int] {
private var currentPos = 0
private def feedCP(): Int = {
assume(currentPos<=data.size)
if(currentPos==data.size) {
imp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.