instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
Explain and rewrite the following Scala code: | def fileLines(file: java.io.File) =
scala.io.Source.fromFile(file).getLines.toList
val filesHere = new java.io.File("/home/arehus/git/programmingInScala").listFiles
def grep(pattern: String) =
for {
f <- filesHere
if !f.isHidden
if f.isDirectory
scalaFile <- f.listFiles()
if scalaFile.getName.... |
Explain and rewrite the following Scala code: | package gh.test.gh3
import gh3.models.GH3Head
import net.liftweb.json._
import org.scalatest.{FlatSpec, Matchers}
class GH3HeadTest extends FlatSpec with Matchers
{
"A valid GH3Head" should "be correctly parsed" in {
val json = parse(
"""
| {
|
| "label":"baxterth... |
Explain and rewrite the following Scala code: | package gapt.examples.tip.isaplanner
import gapt.expr._
import gapt.expr.ty.TBase
import gapt.proofs.Sequent
import gapt.proofs.context.update.InductiveType
import gapt.proofs.gaptic._
import gapt.proofs.gaptic.tactics.AnalyticInductionTactic._
object prop_49 extends TacticsProof {
// Sorts
ctx += TBase( "sk" )
... |
Explain and rewrite the following Scala code: | package io.github.tdhd.robakka.behaviours
import io.github.tdhd.robakka._
import io.github.tdhd.robakka.Agent.MoveCommand
case object FollowPlantBehaviour extends BaseBehaviour {
def act(entity: World.AgentEntity, worldState: World.StateContainer) = {
val plants = BehaviourHelpers.entities2MoveCommand(entity, ... |
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 Intel Corporation under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* Intel Corporation licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use t... |
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 scala
package reflect
package runtime
import scala.reflect.internal.settings.MutableSettings
/** The Settings class for runtime reflection.
* This should be refined, so that settings are settable via command
* line options or properties.
*/
private[reflect] class Settings extends MutableSettings {
tra... |
Explain and rewrite the following Scala code: | /*
* Copyright 2016 Mediative
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in... |
Explain and rewrite the following Scala code: | /*
* Copyright 2014 Marconi Lanna
*
* 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 common
import org.joda.time.format.{DateTimeFormat, DateTimeFormatter}
import anorm._
import org.joda.time.DateTime
import java.sql.Timestamp
import anorm.TypeDoesNotMatch
import anorm.MetaDataItem
object AnormExtension {
val dateFormatGeneration: DateTimeFormatter = DateTimeFormat.forPattern("yyyyMMddHH... |
Explain and rewrite the following Scala code: | //: ----------------------------------------------------------------------------
//: Copyright (C) 2015 Verizon. 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 Licen... |
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 processes.tfl
object TFLProcessVariables {
val TIMEOUT: Int = 2000
val TIMEOUT_INCREMENT: Int = 1000
val LINE_TOLERANCE_IN_RELATION_TO_CURRENT_TIME = 30 //in Seconds
}
|
Explain and rewrite the following Scala code: | package org.jetbrains.sbt
package project
import com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportProvider
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import javax.swing.Icon
/**
* @author Pavel Fatin
*/
final class SbtProjectImportP... |
Explain and rewrite the following Scala code: | /*
* Copyright 2009-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 applica... |
Explain and rewrite the following Scala code: | /*
* This file is part of eCobertura.
*
* Copyright (c) 2009, 2010 Joachim Hofer
* All rights reserved.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/le... |
Explain and rewrite the following Scala code: | /**
* Copyright 2015 Zaradai
*
* 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 writ... |
Explain and rewrite the following Scala code: | package scorex.benchmarks
import org.openjdk.jmh.annotations._
import org.openjdk.jmh.infra.Blackhole
import org.openjdk.jmh.profile.GCProfiler
import org.openjdk.jmh.runner.options.OptionsBuilder
import org.openjdk.jmh.runner.{Runner, RunnerException}
import scorex.benchmarks.Base16Benchmark.BenchmarkState
import sco... |
Explain and rewrite the following Scala code: | package gitbucket.core.util
import gitbucket.core.model.{Session, Issue}
import gitbucket.core.service.{RepositoryService, AccountService, IssuesService, SystemSettingsService}
import gitbucket.core.servlet.Database
import gitbucket.core.view.Markdown
import scala.concurrent._
import ExecutionContext.Implicits.global... |
Explain and rewrite the following Scala code: | package chandu0101.scalajsreact.util
import scala.scalajs.js
object Generator {
val reactJSPropsToWrapperPropsMap = Map(
"PropTypes.bool" -> "UndefOr[Boolean]=undefined",
"PropTypes.func" -> "UndefOr[js.Function] = undefined ",
"PropTypes.Date" -> "UndefOr[js.Date] = undefined ",
"PropTypes.numbe... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala.failed.typeInference
import org.intellij.lang.annotations.Language
import org.jetbrains.plugins.scala.annotator._
import org.jetbrains.plugins.scala.annotator.element.ScConstructorInvocationAnnotator
import org.jetbrains.plugins.scala.base.SimpleTestCase
import org.jetbrains.plugins... |
Explain and rewrite the following Scala code: | // Copyright 2017 EPFL DATA Lab (data.epfl.ch)
//
// 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... |
Explain and rewrite the following Scala code: | package models
import Category.Category
import scala.math._
/** Location
* @author Stephen Johnson
*/
object Location {
implicit object LocationDistMeasurable extends DistMeasurable[Location] {
def distance(first: Location, second: Location) = first.coord - second.coord
}
}
trait Location {
def coord: Coo... |
Explain and rewrite the following Scala code: | package is.hail.expr
import is.hail.asm4s
import is.hail.asm4s._
import is.hail.expr.ir.functions.IRFunctionRegistry
import is.hail.types.physical._
import is.hail.types.physical.stypes.{SCode, SValue}
import is.hail.types.virtual._
import is.hail.types.{coerce => tycoerce, _}
import is.hail.utils._
import java.util.... |
Explain and rewrite the following Scala code: | package com.horstmann.impatient {
package people {
class Person(val name: String) {
val friends = new collection.mutable.ArrayBuffer[Person]
// Doesn't pick up collection from com.horstmann.collection
def description = name + " with friends " +
friends.map(_.name).mkString(", ")
}
... |
Explain and rewrite the following Scala code: | /*
* Copyright 2015 Matt Massie
*
* 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: | package score.money
import java.math.{BigDecimal => JBigDecimal}
import java.math.{MathContext => JMathContext}
import java.math.{RoundingMode => JRoundingMode}
import scala.math.BigDecimal.RoundingMode
import scala.math.BigDecimal.RoundingMode.RoundingMode
import score.money.Percent._
import score.lang.RareException
... |
Explain and rewrite the following Scala code: | package leo.agents
package impl
import leo.datastructures.context.Context
import leo.datastructures.impl.Signature
import leo.datastructures.===
import leo.datastructures.blackboard.FormulaStore
import leo.datastructures.term.Term
import leo.datastructures.Role_Definition
import Term._
import java.io.{PrintWriter, Fil... |
Explain and rewrite the following Scala code: | package com.twitter.finagle.http.filter
import com.twitter.conversions.DurationOps._
import com.twitter.finagle.Service
import com.twitter.finagle.http.{Request, Response}
import com.twitter.util.{Await, Future}
import org.scalatest.funsuite.AnyFunSuite
class AddResponseHeadersFilterTest extends AnyFunSuite {
test(... |
Explain and rewrite the following Scala code: | package net.nomadicalien.ch1
object Listing1_3 {
import Listing1_2._
sealed trait Criteria[T] //not sure why this needs to be a generic?
trait AccountRepository {
def query(accountNo: String): Option[Account]
def query(criteria: Criteria[Account]): Seq[Account]
def write(accounts: Seq[Account]): Bo... |
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2012 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: | package japgolly.scalajs.react.extra.router
import japgolly.scalajs.react._
import japgolly.scalajs.react.internal.CoreGeneral._
import japgolly.scalajs.react.internal.EffectUtil
import japgolly.scalajs.react.util.Effect.Sync
import japgolly.scalajs.react.vdom.html_<^._
import org.scalajs.dom.html
/** Router controll... |
Explain and rewrite the following Scala code: | package com.garnercorp.swdvm.statistics
import com.garnercorp.swdvm.{CompositeElapsed, Elapsed}
import org.scalatest.{FunSuite, Matchers}
class ProjectDistributionUTest extends FunSuite with Matchers {
test("an empty distribution should have no task distribution") {
new ProjectDistribution(Vector.empty[TaskDist... |
Explain and rewrite the following Scala code: | package com.sandinh.couchbase
import javax.inject.Inject
import com.google.inject.{Guice, AbstractModule}
import org.specs2.concurrent.ExecutionEnv
import org.specs2.specification.core.{Env, Fragments}
import scala.concurrent.duration._
import com.typesafe.config.{ConfigFactory, Config}
import org.specs2.matcher.Match... |
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: | /*
* Wire
* Copyright (C) 2016 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This progr... |
Explain and rewrite the following Scala code: | package collins.callbacks
import java.lang.reflect.Method
trait MethodArguments {
def methodArity(method: Method): Int =
method.getParameterTypes.size
def isZeroArityMethod(method: Method): Boolean =
methodArity(method) == 0
}
|
Explain and rewrite the following Scala code: | /* __ *\\
** ________ ___ / / ___ __ ____ Scala.js Test Suite **
** / __/ __// _ | / / / _ | __ / // __/ (c) 2013, LAMP/EPFL **
** __\\ \\/ /__/ __ |/ /__/ __ |/_// /_\\ \\ http://scala-js.org/ **
** /____/\\___/... |
Explain and rewrite the following Scala code: | package provingground.induction
/**
* an earlier implementation of induction, without clean separation of codomain scala types;
* use [[induction]] instead
*/
package object coarse {}
|
Explain and rewrite the following Scala code: | /*
* Copyright 2015 – 2016 Martin Seeler
*
* 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: | /**
* Digi-Lib-Mesh - distributed mesh library for Digi components
*
* Copyright (c) 2012-2013 Alexey Aksenov ezh@ezh.msk.ru
*
* 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
*
* h... |
Explain and rewrite the following Scala code: | package models.daos
import java.util.UUID
import models.AuthToken
import org.joda.time.DateTime
import scala.concurrent.Future
trait AuthTokenDAO extends AuthTokenDAOMinimal {
def findall(): Future[List[AuthToken]]
}
/**
* Give access to the [[AuthToken]] object.
*/
trait AuthTokenDAOMinimal {
/**
* Find... |
Explain and rewrite the following Scala code: | package com.syedatifakhtar.actor
import akka.actor.SupervisorStrategy.Restart
import akka.actor._
import com.syedatifakhtar.Configuration.PlaylistConfigurations
import com.syedatifakhtar.actor.YoutubeDownloadManager._
import com.syedatifakhtar.actor.YoutubeDownloaderProxySupervisor.{DownloadStatus, DownloadVideo, Fail... |
Explain and rewrite the following Scala code: | package dhg.ccg.parse.dep
import org.junit.Test
import dhg.util._
import org.junit.Assert._
import dhg.ccg.cat._
import dhg.ccg.tagdict.SimpleTagDictionary
import dhg.ccg.parse._
import dhg.ccg.parse.pcfg._
class DepParserEvaluatorTests {
@Test
def evaluate1() {
val s = cat"S".asInstanceOf[AtomCat]
val n... |
Explain and rewrite the following Scala code: | package com.tvunetworks.scala.util
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.OutputStreamWriter
import java.net.HttpURLConnection
import java.net.URL
import java.util.Calendar
import org.apache.log4j.Logger
/**
* @author RichardYao
* @date 2017?4?26?
*/
object HttpUtil {
... |
Explain and rewrite the following Scala code: | /*
* Copyright 2017 Pere Villega
*
* 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 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: | /*
* 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 sims.test.gui
package scenes
import sims.dynamics._
import sims.math._
import sims.dynamics._
object JointScene extends Scene {
override def init() = {
val b1 = new Body(new Circle(0.1)) {fixed = true}
val b2 = new Body(new Rectangle(0.1, 0.5)) {position = Vector2D(2,2)}
val j = new DistanceJoint(b1,... |
Explain and rewrite the following Scala code: | package com.campudus.tableaux
import org.vertx.scala.core.json.{JsonArray, JsonObject}
import scala.util.{Failure, Success, Try}
sealed trait ArgumentCheck[A] extends Product with Serializable {
def map[B](f: A => B): ArgumentCheck[B]
def flatMap[B](f: A => ArgumentCheck[B]): ArgumentCheck[B]
def get: A
... |
Explain and rewrite the following Scala code: |
package scalation.linalgebra
/** The gen package contains generic classes, traits and objects for linear
* algebra, including vectors and matrices for types implementing `Numeric`.
* Tend to run more slowly than the specialized versions in linalgebra.
*/
package object gen { }
|
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2010-2011 LShift Ltd.
*
* 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... |
Explain and rewrite the following Scala code: | package scife.enumeration
package parallel
package memoization
package scope
import scife.enumeration.memoization._
import java.util.concurrent.LinkedBlockingQueue
import scala.collection.JavaConversions._
class AccumulatingConcurrentScope extends MemoizationScope {
val memoizations = new LinkedBlockingQueue[Memo... |
Explain and rewrite the following Scala code: | import org.specs2.mutable._
import org.specs2.runner._
import org.junit.runner._
import play.api.test._
import play.api.test.Helpers._
@RunWith(classOf[JUnitRunner])
class ApplicationSpec extends Specification {
"HTML service" should {
"Send 200 on /" in new WithApplication {
val home = route(app, FakeR... |
Explain and rewrite the following Scala code: | import play.api._
import play.api.mvc._
import play.api.mvc.Results._
import play.api.libs.concurrent.Akka
import play.api.Play.current
import akka.actor.Props
import utils.CleanUpActor
import concurrent.duration._
import utils.CleanUp
import play.api.libs.concurrent.Execution.Implicits._
import utils.Analyze... |
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: | package com.ldaniels528.broadway.core.util
import java.net.{HttpURLConnection, URL}
import akka.actor.ActorSystem
import org.slf4j.LoggerFactory
import scala.collection.concurrent.TrieMap
import scala.concurrent.duration._
import scala.util.Try
/**
* HTTP Monitor
* @param system the given [[ActorSystem]]
* @auth... |
Explain and rewrite the following Scala code: | package io.soheila.um.vos.accounts
import play.api.libs.json.Json
/**
* The form data.
*
* @param email The email of the user.
* @param password The password of the user.
* @param rememberMe Indicates if the user should stay logged in on the next visit.
*/
case class SignInVO(
email: String,
password: Strin... |
Explain and rewrite the following Scala code: | /*
* MessageViewImpl.scala
* (Cord)
*
* Copyright (c) 2015-2020 Hanns Holger Rutz.
*
* This software is published under the GNU Lesser General Public License v2.1+
*
*
* For further information, please contact Hanns Holger Rutz at
* contact@sciss.de
*/
package de.sciss.cord
package view
package impl
im... |
Explain and rewrite the following Scala code: | package dao.tenant
import java.sql.Date
import java.time.LocalDate
import java.util.UUID
import io.strongtyped.active.slick._
import models.helpers.{TenantEntityActions, BelongsToTenantTable}
import slick.ast.BaseTypedType
import io.strongtyped.active.slick.Lens._
import slick.lifted.ProvenShape
import scala.languag... |
Explain and rewrite the following Scala code: |
package views.html
import play.templates._
import play.templates.TemplateMagic._
import play.api.templates._
import play.api.templates.PlayMagic._
import models._
import controllers._
import java.lang._
import java.util._
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._
import play.... |
Explain and rewrite the following Scala code: | import sbt._
import Keys.name
object TestBuild extends MakeBuild
{
lazy val a = proj("a", ".")
}
object SecondBuild extends MakeBuild
{
lazy val b = proj("b", "b")
}
trait MakeBuild extends Build
{
import AddSettings._
def proj(id: String, dir: String) = Project(id, file(dir), settings = Seq( name := id ) ).settin... |
Explain and rewrite the following Scala code: | package org.danielnixon.progressive.services
import org.danielnixon.progressive.extensions.dom.NodeListSeq
import org.scalajs.dom.Window
import org.scalajs.dom.html.Element
import org.scalajs.dom.raw.HTMLFormElement
import org.danielnixon.saferdom.implicits._
class FocusManagementService(window: Window, scrollOffset:... |
Explain and rewrite the following Scala code: | package models.actors.dataimport
import javax.inject.Inject
import akka.actor.{Actor, Props}
import akka.event.LoggingReceive
import models.entity.{DataImport, Task}
import models.service.TaskService
import play.api.Logger
import play.api.libs.concurrent.InjectedActorSupport
import scala.concurrent.{Execu... |
Explain and rewrite the following Scala code: | class A[T](val x:T)
class B[T](override val x:T) extends A[T](x)
class C[T](val x:T, val y: Int, val z: Boolean)
class D[T](override val x:T, y: Int, z: Boolean) extends C[T](x, y, z)
trait X(val x: Int, y: Int, z: Int)
trait Y(override val x: Int, y: Int, z: Int) extends X
class Z(override val x: Int, y: Int, z: Int... |
Explain and rewrite the following Scala code: | package ohnosequences.compota.cli
import com.amazonaws.services.identitymanagement.model._
import com.amazonaws.services.identitymanagement.AmazonIdentityManagementClient
object RoleCreator {
def roleExists(role: String, iam: AmazonIdentityManagementClient): Boolean = {
try {
iam.getRole(new GetRoleReque... |
Explain and rewrite the following Scala code: | package molecule.benchmarks.comparison.actors
object ExecutorConfig {
import mbench.benchmark._
import molecule.platform.Executor
def apply(executorName: String, executor: Int => Executor): RuntimeConfig[Int, Executor] =
Config.runtime[Int, Executor](
executorName,
executor,
_.shutdownNow... |
Explain and rewrite the following Scala code: | package org.machine.engine.authentication
import java.util.Random;
import org.scalatest._
import org.scalatest.mock._
class PasswordSpec extends FunSpecLike with Matchers with BeforeAndAfterAll{
import PasswordTools._;
var generator:Random = null
override def beforeAll(){
val seed = generateSeed()
gene... |
Explain and rewrite the following Scala code: | /*
* EtherNet/IP
* Copyright (C) 2014 Kevin Herron
*
* 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) any later version.
*
*... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2017 CyberAgent
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish,... |
Explain and rewrite the following Scala code: | package com.datastax.driver.spark.rdd.reader
import com.datastax.driver.core.Row
import com.datastax.driver.spark.connector.TableDef
import com.datastax.driver.spark.mapper.ColumnMapper
import scala.reflect.runtime.universe._
/** Creates [[RowReader]] objects prepared for reading rows from the given Cassandra table.... |
Explain and rewrite the following Scala code: | package models.mining
import play.api.libs.json.JsObject
/**
* Created by chetan on 28/04/15.
*/
package object mlret {
trait MOutput {
def output: JsObject
}
/*
val conf = try {
new SparkConf().setAppName("Veracious-Retriver").setMaster("spark://Chetans-MacBook-Air.local:7077")
} catch {
ca... |
Explain and rewrite the following Scala code: | package calculator
object Polynomial {
def computeDelta(a: Signal[Double], b: Signal[Double], c: Signal[Double]): Signal[Double] = {
Signal(b() * b() - 4.0 * a() * c())
}
def computeSolutions(a: Signal[Double], b: Signal[Double], c: Signal[Double], delta: Signal[Double]): Signal[Set[Double]] = {
Signal... |
Explain and rewrite the following Scala code: | package mr.merc.economics.ai
import mr.merc.economics.StateBudget
import mr.merc.politics.EconomyPosition
import mr.merc.politics.State
object StateBudgetAI {
def apply(): StateBudgetAI = new SocialDemocraticStateBudgetAI()
}
trait StateBudgetAI {
def balanceBudget(state: State): Unit
}
class SocialDemocraticSt... |
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2010-2011 LShift Ltd.
*
* 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... |
Explain and rewrite the following Scala code: | package scalariform.lexer
import scala.collection.mutable.Stack
/**
* Keeping track of nesting level of XML within Scala.
*/
trait ModeStack { self: ScalaLexer ⇒
private val modeStack = new Stack[LexerMode]
private var currentRegionStart: Int = 0
modeStack.push(new ScalaMode)
protected def popMode() {
... |
Explain and rewrite the following Scala code: | package controllers
import java.util.Date
import scala.io.Source
import scala.xml
import play.api._
import play.api.mvc._
// stealing liberally from
// https://gist.github.com/585235/bf328d90d094305121cec0ba2a646ce0093fa654
// http://stackoverflow.com/questions/7769454/scala-strip-all-html-tags-from-string-except-li... |
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: | /*
* Part of NDLA image-api.
* Copyright (C) 2017 NDLA
*
* See LICENSE
*/
package no.ndla.imageapi.model.api
import java.text.SimpleDateFormat
import java.util.Date
import no.ndla.imageapi.ImageApiProperties
import org.scalatra.swagger.annotations.{ApiModel, ApiModelProperty}
import scala.annotation.meta.field... |
Explain and rewrite the following Scala code: | package com.eharmony.aloha.dataset.vw.cb
import com.eharmony.aloha.FileLocations
import com.eharmony.aloha.dataset.SparseFeatureExtractorFunction
import com.eharmony.aloha.dataset.json.SparseSpec
import com.eharmony.aloha.dataset.vw.cb.json.VwContextualBanditJson
import com.eharmony.aloha.dataset.vw.unlabeled.VwRowCre... |
Explain and rewrite the following Scala code: | package uk.gov.gds.ier.transaction.ordinary.name
import uk.gov.gds.ier.test.FormTestSuite
class NameFormTests
extends FormTestSuite
with NameForms {
it should "error out on empty json" in {
val js = JsNull
nameForm.bind(js).fold(
hasErrors => {
hasErrors.errors.size should be(5)
h... |
Explain and rewrite the following Scala code: | package org.zalando.grafter.macros
import cats.data.Reader
object ReadersMacroTest {
val r1: Reader[AppConfig, C1] =
AppConfig.c1Reader
val r1Implicit: Reader[AppConfig, C1] =
implicitly[Reader[AppConfig, C1]]
val r2: Reader[AppConfig, C2] =
AppConfig.c21Reader
val r2Implicit: Reader[AppConfi... |
Explain and rewrite the following Scala code: | package amailp.intellij.robot.extensions
import com.intellij.psi.{ElementDescriptionLocation, PsiElement}
import com.intellij.usageView.UsageViewLongNameLocation
import amailp.intellij.robot.findUsage.UsageFindable
class ElementDescriptionProvider extends com.intellij.psi.ElementDescriptionProvider {
def getElement... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2002-2018 "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 Foundatio... |
Explain and rewrite the following Scala code: | package better
import java.io.StreamTokenizer
import java.nio.charset.Charset
import scala.collection.mutable
import scala.util.{Failure, Success, Try}
package object files extends Implicits {
/** Default array buffer size
* Seems like a good value used by JDK: (see: java.io.BufferedInputStream.DEFAULT_BUFFER... |
Explain and rewrite the following Scala code: | package de.tototec.sbuild.internal
import org.scalatest.FreeSpec
class UtilTest extends FreeSpec {
"unzip" in {
pending
}
} |
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 org.scalamu.plugin.mutators.controllflow
import org.scalamu.plugin.mutators.{AbstractBinaryOperatorMutator, NumericTypesSupport}
import org.scalamu.plugin.{MutatingTransformer, ScalamuScalacConfig}
import scala.runtime._
import scala.tools.nsc.Global
/**
* Mutation operator that swaps `until` and `to` metho... |
Explain and rewrite the following Scala code: | package de.kaufhof.pillar
import java.util.Date
import com.datastax.driver.core.exceptions.InvalidQueryException
import com.datastax.driver.core.querybuilder.QueryBuilder
import org.scalatest.{BeforeAndAfter, FeatureSpec, GivenWhenThen, Matchers}
class PillarLibraryAcceptanceSpec extends FeatureSpec
with Cassandra... |
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: | /*
* 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 dotty.tools
package dotc
package core
package tasty
import util.Positions._
import collection.mutable
import TastyBuffer.Addr
object PositionUnpickler {
type AddrToPosition = mutable.HashMap[Addr, Position]
}
/** Unpickler for tree positions */
class PositionUnpickler(reader: TastyReader) {
import Posit... |
Explain and rewrite the following Scala code: | package com.karasiq.shadowcloud.mailrucloud
import com.karasiq.shadowcloud.config.ConfigProps
import com.karasiq.shadowcloud.providers.StorageProvider
class MailRuCloudStorageProvider extends StorageProvider {
override val storageTypes = Set("mailrucloud")
override def storages = {
case sp if sp.storageType ... |
Explain and rewrite the following Scala code: | package streams
import scala.concurrent.Promise
import scala.concurrent.duration._
import scala.util.Random
import akka.Done
import akka.actor._
import akka.stream.scaladsl._
import akka.stream.testkit.scaladsl._
import akka.testkit._
import org.scalatest.matchers.must.Matchers
import org.scalatest.wordspec.AnyWordS... |
Explain and rewrite the following Scala code: | case object Empty extends Stream[Nothing]
case class Cons[+A](h: () => A, t: () => Stream[A]) extends Stream[A]
object Stream {
def cons[A](hd: => A, tl: => Stream[A]): Stream[A] = {
lazy val head = hd
lazy val tail = tl
Cons(() => head, () => tail)
}
def empty[A]: Stream[A] = Empty
def apply[A](... |
Explain and rewrite the following Scala code: | package infra.sockjs
import play.api.test.{WithApplication, FakeRequest, PlaySpecification}
import akka.actor._
import akka.actor.Terminated
import scala.concurrent.Promise
import scala.concurrent.duration.FiniteDuration
import play.api.libs.json.{JsNumber, JsString}
/**
* @author alari (name.alari@gmail.com)
* @si... |
Explain and rewrite the following Scala code: | package com.github.agourlay.cornichon.steps.regular.assertStep
import cats.scalatest.{ ValidatedMatchers, ValidatedValues }
import org.scalatest.{ Matchers, WordSpec }
class AssertionSpec extends WordSpec
with Matchers
with ValidatedMatchers
with ValidatedValues {
"Assertion" when {
"compose with And" m... |
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 ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.