instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2009-2011 Mathias Doenitz
* Adapted and extended in 2017 by Eugene Yokota
*
* 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... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | object Monoid {
implicit def listMonoid[A]: Monoid[List[A]] = new Monoid[List[A]] {
def mempty: List[A] = List()
def mappend(m1: List[A], m2: List[A]): List[A] = m1 ++ m2
}
} |
Explain and rewrite the following Scala code: | package daos.product
import models.product.Product
import daos.BaseDAO
import java.lang.Long
import models.product.Sku
class SkuDAO extends BaseDAO[Sku, Long] {
} |
Explain and rewrite the following Scala code: | /**
* Copyright (c) 2013-2015 Patrick Nicolas - Scala for Machine Learning - All rights reserved
*
* The source code in this file is provided by the author for the sole purpose of illustrating the
* concepts and algorithms presented in "Scala for Machine Learning". It should not be used to
* build commercial ap... |
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 play.api.mvc._
object Application extends Controller {
def main = Action {
Ok(views.html.main("Main page"))
}
}
|
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... |
Explain and rewrite the following Scala code: | package org.scalameter
import scala.collection.mutable
object MethodCounter {
private val counter = mutable.Map.empty[String, Int]
def reset(): Unit = {
counter.clear()
}
def counts: Map[String, Int] = counter.toMap
def called(method: String): Unit = {
counter.synchronized {
counter += (me... |
Explain and rewrite the following Scala code: | package one.lockstep.util.concurrent
import java.util
import java.util.concurrent.{Callable, ScheduledExecutorService, ScheduledFuture}
import one.lockstep.util.japi._
import scala.concurrent.duration._
class DelegatingScheduledExecutorService(service: ScheduledExecutorService)
extends ScheduledExecutorService {
... |
Explain and rewrite the following Scala code: | package concrete.constraint.semantic
import bitvectors.BitVector
import concrete._
import concrete.constraint.Constraint
import concrete.heuristic.{Assign, Remove}
import concrete.util.BitSetQueue
import cspom.Statistic
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
class NoGoods(scope:... |
Explain and rewrite the following Scala code: | package org.dataalgorithms.chap26.scala
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
/**
*
* Gene Aggregation by Individual
*
* @author Gaurav Bhardwaj (gauravbhardwajemail@gmail.com)
*
* @editor Mahmoud Parsian (mahmoud.parsian@yahoo.com)
*
*/
object GeneAggregationByIndividual {
... |
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: | package com.twitter.finagle.thriftmux
import com.twitter.finagle.{ListeningServer, ThriftMux}
import com.twitter.conversions.DurationOps._
import com.twitter.finagle.{Filter, Service, SimpleFilter}
import com.twitter.finagle.thriftmux.thriftscala.TestService
import com.twitter.finagle.thriftmux.thriftscala.TestService... |
Explain and rewrite the following Scala code: | package com.olegych.scastie.client.components.editor
import com.olegych.scastie.api
import com.olegych.scastie.client.AnsiColorFormatter
import codemirror.TextAreaEditor
import org.scalajs.dom
import org.scalajs.dom.raw.HTMLDivElement
import japgolly.scalajs.react.Callback
object ProblemAnnotations {
def apply(... |
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: | package au.com.dius.pact.consumer
import au.com.dius.pact.consumer.dsl.DslPart
import au.com.dius.pact.consumer.specs2.VerificationResultAsResult
import au.com.dius.pact.model._
import org.specs2.mutable.Specification
import org.specs2.specification.core.Fragments
import scala.collection.JavaConverters._
trait UnitS... |
Explain and rewrite the following Scala code: | package br.unb.cic.poo.gol.base
class Helio extends Regra {
var nome = "Helio"
/* verifica se uma celula deve ser mantida viva */
def shouldKeepAlive(i: Int, j: Int): Boolean = {
(GameEngine.cells(i)(j).isAlive) &&
(GameEngine.numberOfNeighborhoodAliveCells(i, j) == 3)
}
/* verifica se uma celul... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala
package codeInsight.intention.booleans
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import org... |
Explain and rewrite the following Scala code: | /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distrib... |
Explain and rewrite the following Scala code: | package build.unstable.sonicd.source
import build.unstable.sonic.JsonProtocol._
import build.unstable.sonic.model.{OutputChunk, SonicMessage, TypeMetadata}
import spray.json._
import scala.annotation.tailrec
import scala.collection.mutable
object SonicdPublisher {
case class ParsedQuery(select: Option[Vector[Stri... |
Explain and rewrite the following Scala code: | import leon.annotation._
import leon.lang._
import leon.lang.synthesis._
object SparseVector {
sealed abstract class SparseVector
case class Cons(index: Int, value : Int, tail: SparseVector) extends SparseVector
case object Nil extends SparseVector
sealed abstract class Option
case class Some(v: Int) exten... |
Explain and rewrite the following Scala code: | package com.datastax.driver.spark.rdd
sealed trait ColumnSelector
case object AllColumns extends ColumnSelector
case class SomeColumns(columns: String*) extends ColumnSelector
|
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 com.github.novamage.svalidator.binding.binders.special
import com.github.novamage.svalidator.binding.binders.{JsonTypedBinder, TypedBinder}
import com.github.novamage.svalidator.binding.{BindingFailure, BindingPass, BindingResult}
import io.circe.{ACursor, HCursor}
/** Binds options of a given type, provided ... |
Explain and rewrite the following Scala code: | package cc.factorie.app.nlp.load
import cc.factorie.app.nlp._
import java.io.{InputStreamReader, BufferedReader, FileReader, File}
import cc.factorie.app.nlp.coref.{CorefOptions, Mention, WithinDocEntity, WithinDocCoref}
import cc.factorie.app.nlp.phrase.{OntonotesPhraseEntityType, Phrase}
import cc.factorie.app.nlp.p... |
Explain and rewrite the following Scala code: | package models.daos
import java.util.UUID
import com.mohiva.play.silhouette.api.LoginInfo
import models.User
import scala.concurrent.Future
/**
* Give access to the user object.
*/
trait UserDAO {
/**
* Finds a user by its login info.
*
* @param loginInfo The login info of the user to find.
* @retu... |
Explain and rewrite the following Scala code: | /*****************************************
Emitting Generated Code
*******************************************/
class TPCH_Q1_hor_seq extends ((Array[Array[java.lang.String]])=>(Array[scala.Tuple2[Char, scala.Tuple2[Char, scala.Tuple2[Double, scala.Tuple2[Double, scala.Tuple2[Double, scala.Tuple2[Do... |
Explain and rewrite the following Scala code: | /*
* Copyright 2018 Analytics Zoo 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... |
Explain and rewrite the following Scala code: | package tutorial
object CreatingNewClasses
class FieldsArePrivate(index: Int, name: String)
|
Explain and rewrite the following Scala code: | package com.shorrockin.cascal.model
import java.nio.ByteBuffer
/**
* a type of column container which holds standard columns.
*
* @author Chris Shorrock
*/
trait StandardColumnContainer[ColumnType, SliceType, ValueType] extends ColumnContainer[ColumnType, SliceType] {
def \\(name:ByteBuffer):ColumnType
def \\... |
Explain and rewrite the following Scala code: | package com.bradbrok.filmomatic
import akka.actor.Actor
import com.bradbrok.filmomatic.JobActor.Start
import com.bradbrok.filmomatic.Message.Request
import com.bradbrok.filmomatic.state.Plan
object JobActor {
trait Start extends Request {
def plan: Plan
}
}
class JobActor extends Actor {
var plan: Plan = _... |
Explain and rewrite the following Scala code: | package org.machine.engine.communication
import akka.actor.ActorSystem
import akka.http.javadsl.model.HttpHeader;
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.model.StatusCodes
import akka.stream.{ActorMaterializer}
import akka.util.Timeout
import scala... |
Explain and rewrite the following Scala code: | // Test that reference types are no longer nullable.
class Basic {
val no: Nothing = ???
val n: Null = null
val n2: Null = no
val any1: Any = null
val any2: Any = n
val matchable1: Matchable = null
val matchable2: Matchable = n
val s1: String = null // error
val s2: String = n // error
val s3... |
Explain and rewrite the following Scala code: | package tech.sourced.berserker.normalizer
import org.apache.spark.SparkConf
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.SparkSession
import tech.sourced.berserker.normalizer.model.Schema
import tech.sourced.berserker.normalizer.service.ExtractorService
import scala.util.Properties
/**
* Start Berse... |
Explain and rewrite the following Scala code: | package biz.mediabag.qcoder.domain
import java.nio._
import java.nio.channels._
import java.io._
abstract class Stream[T <: Frame] {
def frames: Seq[T]
}
abstract class Container[T <: Stream[_]] {
def formatName:String
def longFormatName:String
def startTime:Option[Long]
... |
Explain and rewrite the following Scala code: | /* ___ _ ___ _ _ *\
** / __| |/ (_) | | The SKilL Generator **
** \__ \ ' <| | | |__ (c) 2013-16 University of Stuttgart **
** |___/_|\_\_|_|____| see LICENSE ... |
Explain and rewrite the following Scala code: | /*
* Copyright 2017-2018 Iaroslav Zeigerman
*
* 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 ... |
Explain and rewrite the following Scala code: | import org.apache.spark.{SparkContext, SparkConf}
/**
* Created by jie on 4/6/16.
* userid, itemid, behavior, geohash, category, time
* item, geohash, category
*/
object userPut {
def main(args: Array[String]): Unit = {
if(args.length < 2){
println("Usage args")
System.exit(1)
}... |
Explain and rewrite the following Scala code: | package me.reminisce.stats.server
import scala.util.Properties._
object ApplicationConfiguration {
val serverPort = envOrElse("STATS_PORT", "7777").toInt
val hostName = envOrElse("STATS_HOST", "localhost")
val mongoHost = envOrElse("MONGODB_HOST", hostName)
val mongodbName = envOrElse("REMINISCE_STATS_MONG... |
Explain and rewrite the following Scala code: | package stronghold.strings
/**
* problem description: http://rosalind.info/problems/subs/
*/
object FindingAMotifInDna {
object SampleData {
val sample: List[String] =
List(
"GATATATGCATATACTT",
"ATAT"
)
}
import scala.annotation.tailrec
import SampleData.sample
import ... |
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.jlprat.gameserver.become.actor
import akka.actor.{Props, ActorSystem}
import akka.testkit._
import com.github.jlprat.gameserver.become.actors.Table
import com.github.jlprat.gameserver.become.model._
import com.github.jlprat.gameserver.become.protocol.ClientProtocol.Out.WrongAction
import com.github.... |
Explain and rewrite the following Scala code: | /*
* This file is part of the regex project.
*
* 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: | /*
* 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 quickcheck
import common._
import org.scalacheck._
import Arbitrary._
import Gen._
import Prop.{forAll, BooleanOperators}
abstract class QuickCheckHeap extends Properties("Heap") with IntHeap {
property("min1") = forAll { a: Int =>
val h = insert(a, empty)
findMin(h) == a
}
lazy val genHeap: ... |
Explain and rewrite the following Scala code: | /*
* Copyright 2001-2008 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 2016 Shyam Anand
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 wri... |
Explain and rewrite the following Scala code: | package com.example.actors
import akka.actor.Actor
import akka.actor.ActorLogging
import org.apache.commons.math3.distribution.NormalDistribution
import scala.util.Random
object MatchEvaluator {
case class Match(id: String, hostValue: Double, awayValue: Double)
case class MatchResult(id: String, hostGoals: Int, ... |
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2009-2011 Scalable Solutions AB <http://scalablesolutions.se>
*/
package akka.routing
import akka.actor.ActorRef
import scala.collection.convert.wrapAsScala._
import scala.collection.immutable.Seq
/**
* An Iterator that is either always empty or yields an infinite number of Ts.
*/
trait Infin... |
Explain and rewrite the following Scala code: | /**
* Copyright 2011-2013 StackMob
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... |
Explain and rewrite the following Scala code: | /*
Copyright 2013 Twitter, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distr... |
Explain and rewrite the following Scala code: | package controllers
import java.sql.Timestamp
import java.time.{Instant, ZoneId, ZoneOffset, ZonedDateTime}
import java.time.format.DateTimeFormatter
import java.util.Date
import javax.inject.{Inject, Singleton}
import akka.http.scaladsl.model.ContentTypes
import akka.stream.scaladsl.Source
import akka.util.ByteStrin... |
Explain and rewrite the following Scala code: | package picasso.utils.tool.dpiexplorer
import picasso.frontend.dbpGraph.DBPGraphs._
import picasso.model.dbp._
import picasso.math._
import scala.util._
import picasso.utils._
object ToDBP {
protected val safeToken = Thread(new Node("_s", Some("safe")), 0)
protected def errorToken(err: String) = Thread(new Node(... |
Explain and rewrite the following Scala code: | package no.hib.dpf.text.scala.henshin
import no.hib.dpf.text.scala.ct._
import no.hib.dpf.text.scala.ct.mutable._
import no.hib.dpf.text.scala.output.EMFOutput
import scala.collection.mutable.{ Map => MMap }
import scala.collection.mutable.{ Set => MSet }
import scala.collection.JavaConverters.asScalaBufferConverter
... |
Explain and rewrite the following Scala code: | /**
* Part of a blog entry at: http://stevenskelton.ca/threadlocal-variables-scala-futures/
*/
import org.specs2._
import org.specs2.matcher._
import scala.util.DynamicVariable
import scala.concurrent._
import java.util.UUID
class ForkJoinPoolWithDynamicVariableSpec extends mutable.SpecificationWithJUnit {
sequen... |
Explain and rewrite the following Scala code: | /*
This file is part of Static Web Gallery (SWG).
MathMaster is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MathMaster is distribute... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2013-2014 Telefónica Investigación y Desarrollo S.A.U.
*
* 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
*
* Unles... |
Explain and rewrite the following Scala code: | /*
* Copyright 2016 Stephen McIntosh
*
* 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 mbench
import sbt._
import Keys._
import com.typesafe.sbt.git.GitRunner
import com.typesafe.sbt.SbtGit.GitKeys
import com.typesafe.sbt.SbtSite.{ site, SiteKeys }
import com.typesafe.sbt.SbtGhPages.{ ghpages, GhPagesKeys => ghkeys }
import com.typesafe.sbt.SbtGit.GitKeys.gitRemoteRepo
// from https://github.c... |
Explain and rewrite the following Scala code: | /*
* Copyright 2021 ABSA Group Limited
*
* 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 (C) 2015-2015 Paulo Angelo Alves Resende <pa@pauloangelo.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
* published by the Free Software Foundation. You may not use, modify or
* distribute this program und... |
Explain and rewrite the following Scala code: | package lila.irwin
import lila.memo.SettingStore.{ Formable, StringReader }
import play.api.data.Form
import play.api.data.Forms.{ single, text }
import lila.common.Ints
case class IrwinThresholds(report: Int, mark: Int)
private object IrwinThresholds {
private val defaultThresholds = IrwinThresholds(88, 95)
v... |
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 wcs.build
import scala.xml._
import java.io.File
object Tld2Tagj {
val javaKeywords = Set(
"abstract", "continue", "for", "new", "switch",
"assert", "default", "goto", "package", "synchronized",
"boolean", "do", "if", "private", "this",
"break", "double", "implements", "protected", "throw",... |
Explain and rewrite the following Scala code: | package breeze.linalg
import breeze.generic.UFunc
import breeze.linalg.operators.OpDiv
import breeze.linalg.support.ScalarOf
/**
* Normalizes the argument such that its norm is 1.0 (with respect to the argument n).
* Returns value if value's norm is 0.
*/
object normalize extends UFunc with normalizeLowPrio {
im... |
Explain and rewrite the following Scala code: | package org.roelf.scala.aerirc
import java.net.Socket
import java.util.concurrent.TimeUnit
import javax.net.ssl.SSLSocketFactory
import akka.actor._
import org.roelf.scala.aerirc.actors._
import org.roelf.scala.aerirc.handlers._
import org.roelf.scala.aerirc.messages._
import org.roelf.scala.aerirc.user.{IRCUser, TUs... |
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.actor
import scala.collection.immutable
import akka.AkkaException
import akka.dispatch.{ UnboundedDequeBasedMessageQueueSemantics, RequiresMessageQueue, Envelope, DequeBasedMessageQueueSemantics, Mailboxes }
/**
* The `Stash` t... |
Explain and rewrite the following Scala code: | // TODO: fixme
//
// package scala.meta.tests
// package tql
//
// import scala.meta._
// import scala.meta.dialects.Scala211
// import scala.meta.tql._
// import scala.meta.prettyprinters._
// import scala.meta.internal.{ast => impl}
// import scala.meta.syntactic.parseApi._
// import org.scalatest.FunSuite
//
// clas... |
Explain and rewrite the following Scala code: | package scabot
package cli
import scala.concurrent.{ Future, Await }
import scala.concurrent.duration.Duration
class CLI(configName: String)
extends github.GithubApi
with core.Configuration with core.HttpClient with core.Core {
override def configFile =
new java.io.File("./cli.conf")
override def br... |
Explain and rewrite the following Scala code: | package d02
object Runner {
lazy val number2Zero: Number2 = Number2T(() => number2Zero, Item("01"))
def beMinusFromInt(n: Int): Number2 = n match {
case n1 if n1 > 0 => Number2S(() => beMinusFromInt(n1 - 1), Item("$n"))
case 0 => number2Zero
}
// Implement 1
lazy val context1: Context[Un... |
Explain and rewrite the following Scala code: | object test {
val b: scala.Boolean = null
val c: Unit = null
val d: Float = null
val e: AnyVal = null
}
|
Explain and rewrite the following Scala code: | /*
* Copyright (C) 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 agreed... |
Explain and rewrite the following Scala code: | package cromwell.services.instrumentation.impl.statsd
import com.typesafe.config.ConfigFactory
import org.scalatest.{FlatSpec, Matchers}
import scala.concurrent.duration._
class StatsDConfigSpec extends FlatSpec with Matchers {
behavior of "StatsDConfig"
it should "parse correct service configuration" in {
... |
Explain and rewrite the following Scala code: | package deq
import leon._
import mem._
import higherorder._
import lang._
import annotation._
import collection._
import instrumentation._
import math._
import invariant._
/**
* A worst-case constant time, presistent deque based on Okasaki's implementation: Fig.8.4 Pg. 112
* of book "Purely Functional Data Structur... |
Explain and rewrite the following Scala code: | import akka.actor._
case class Participant(name: String , ref: ActorRef) {
} |
Explain and rewrite the following Scala code: | package org.f100ded.play.fakews
import java.net.URI
import akka.stream.Materializer
import akka.stream.scaladsl.Source
import akka.util.ByteString
import play.api.libs.ws.ahc.AhcUtilities
import play.api.libs.ws.{DefaultBodyReadables, StandaloneWSResponse, WSCookie}
class StandaloneFakeWSResponse(val uri: URI, resul... |
Explain and rewrite the following Scala code: | package com.twitter.util.reflect
import com.twitter.util.{Future, Promise, Stopwatch}
import org.junit.runner.RunWith
import org.scalatest.WordSpec
import org.scalatest.junit.JUnitRunner
object ProxySpec {
trait TestInterface {
def foo: String
def bar(a: Int): Option[Long]
def whoops: Int
def theVo... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala
package lang
package psi
package stubs
package elements
package signatures
import _root_.org.jetbrains.plugins.scala.lang.psi.impl.statements.params.ScParameterClauseImpl
import com.intellij.psi.PsiElement
import com.intellij.psi.stubs.{IndexSink, StubElement, StubInputStream, StubO... |
Explain and rewrite the following Scala code: | /*
* Copyright 2014 David Crosson
*
* 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 com.gilt.storeroom
import scala.concurrent._
import scala.concurrent.ExecutionContext.Implicits.global
import org.scalatest.{FunSuite, Matchers}
import org.scalatest.concurrent.ScalaFutures
import scala.collection.mutable.Map
import scala.collection.immutable.{Map => IMap}
object WritableStoreTest {
// sh... |
Explain and rewrite the following Scala code: | package edison.search
import edison.util.SmartSpec
import org.scalactic.TolerantNumerics
class SamplesTest extends SmartSpec {
behavior of "Samples"
val emptySamples = Samples.empty
val oneSample10 = Samples(1 -> 10.0)
val twoSamples10_20 = Samples(1 -> 10.0, 2 -> 20.0)
val twoSamples10_10 = Samples(1 -> ... |
Explain and rewrite the following Scala code: | package com.github.mnotracker.ui
import android.app.{Activity, Dialog, DialogFragment}
import com.github.mnotracker.R
class AlertDialogFragment(message: String, buttons: (String, () => Unit)*)
(implicit activity: Activity)
extends DialogFragment {
import android.content.DialogInterface
... |
Explain and rewrite the following Scala code: | /**
* Copyright 2014 Dropbox, 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... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._
import sbt._
object Dependencies {
val udashVersion = "0.7.1"
val udashJQueryVersion = "1.2.0"
val logbackVersion = "1.1.3"
val jettyVersion = "9.4.11.v20180605"
val akkaVersion =... |
Explain and rewrite the following Scala code: | package eu.henkelmann.actuarius
import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
/**
* Tests Inline Parsing, i.e. emphasis , strong text, links, escapes etc.
*/
@RunWith(classOf[JUnitRunner])
class InlineParsersTest ext... |
Explain and rewrite the following Scala code: | /* Title: Pure/Tools/doc.scala
Author: Makarius
Access to Isabelle documentation.
*/
package isabelle
import scala.util.matching.Regex
object Doc
{
/* dirs */
def dirs(): List[Path] =
Path.split(Isabelle_System.getenv("ISABELLE_DOCS"))
/* contents */
private def contents_lines(): Lis... |
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 ma... |
Explain and rewrite the following Scala code: | /**
* *****************************************************************************
* Copyright (c) 2013 Guillaume DUBUISSON DUPLESSIS <guillaume.dubuisson_duplessis@insa-rouen.fr>.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0... |
Explain and rewrite the following Scala code: | /**
* Copyright (c) 2013 Saddle Development 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 scala.scalanative
package nir
import util.sh
import Shows._
import fastparse.all.Parsed
import org.scalatest._
class InstParserTest extends FlatSpec with Matchers {
val local = Local("test", 1)
val next = Next(local)
val noTpe = Type.None
"The NIR parser" should "parse `Inst.None`" in {
val no... |
Explain and rewrite the following Scala code: | package play.boilerplate.generators
import org.scalatest.{FlatSpec, Matchers}
import play.boilerplate.generators.GeneratorUtils._
import play.boilerplate.generators.logger.LoggerProvider
import play.boilerplate.generators.security.{Play2AuthSecurityProvider, SecurityProvider}
import play.boilerplate.parser.backend.swa... |
Explain and rewrite the following Scala code: | package com.danielwestheide.slickeffecttypes.db
import slick.dbio.{NoStream, DBIOAction}
import slick.driver.H2Driver.api._
import scala.concurrent.Future
class DB[R <: Role](databaseConfiguration: DatabaseConfiguration[R]) {
private val underlyingDatabase = databaseConfiguration.createDatabase()
def run[A, E ... |
Explain and rewrite the following Scala code: | package mesosphere.mesos
import com.twitter.util.NonFatal
import mesosphere.marathon.state.DiskSource
import org.apache.mesos.Protos.Resource.DiskInfo.Source
import org.apache.mesos.Protos.Resource.{ DiskInfo, ReservationInfo }
import org.apache.mesos.{ Protos => MesosProtos }
import org.slf4j.LoggerFactory
import sca... |
Explain and rewrite the following Scala code: | package com.github.libsml.test
import java.io.PrintWriter
import com.github.libsml.aggregation.optimization.DefaultOptimizationAlgorithm
import com.github.libsml.math.function.Function._
import com.github.libsml.math.linalg.Vector
import com.github.libsml.model.classification.{LogisticRegression, LogisticRegressionMo... |
Explain and rewrite the following Scala code: | package sample.snippet
import scala.xml.{NodeSeq,Text}
import net.liftweb.http.{S,DispatchSnippet}
class Service extends DispatchSnippet {
def dispatch = {
case _ => render _
}
def render(xhtml: NodeSeq): NodeSeq = {
fetch
Text("Done!")
}
protected def fetch { Thread.sleep(5000) }
}
class StubS... |
Explain and rewrite the following Scala code: | package com.datawizards.sparklocal.accumulator
trait AccumulatorV2API[IN, OUT] extends Serializable {
/**
* Returns true if this accumulator has been registered.
*
* @note All accumulators must be registered before use, or it will throw exception.
*/
def isRegistered: Boolean
/**
* Returns t... |
Explain and rewrite the following Scala code: | package sjc.delta.circe
import io.circe.{Codec, Json, JsonObject, parser}
import org.scalatest.Matchers
trait JsonSpecUtil extends Matchers {
val jEmptyObject: Json = Json.fromJsonObject(JsonObject.empty)
implicit class JsonSpecOps(json: Json) {
def jsonShouldEqual(expected: String): Unit = json jsonShouldE... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.