instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
Explain and rewrite the following Scala code: | package lore.compiler.semantics.scopes
import lore.compiler.core.Position
import lore.compiler.feedback.Reporter
import lore.compiler.semantics.NamePath
import lore.compiler.semantics.functions.FunctionSignature
import lore.compiler.semantics.scopes.StructConstructorBinding.InstantiationSchema
import lore.compiler.sem... |
Explain and rewrite the following Scala code: | package tv.kazu.chatwork4s.models
case class Room(
roomId: Int,
name: String,
`type`: String,
role: String,
sticky: Boolean,
unreadNum: Int,
mentionNum: Int,
mytaskNum: Int,
messageNum: Int,
fileNum: Int,
taskNum: Int,
iconPath: String,
lastUpdateTime: Int,
/**
* /rooms/<room id> の... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package play.api.http
/**
* A port. This class is defined so that ports can be passed around implicitly.
*/
class Port(val value: Int) extends AnyVal {
override def toString = value.toString
}
|
Explain and rewrite the following Scala code: | package com.twitter.finagle.http.exp
import com.twitter.concurrent.AsyncQueue
import com.twitter.conversions.time._
import com.twitter.finagle.{Service, Status}
import com.twitter.finagle.http
import com.twitter.finagle.http.{BadHttpRequest, Request, Response, Version}
import com.twitter.finagle.http.netty.Netty3Serve... |
Explain and rewrite the following Scala code: | package ch.fram.medlineGeo.crunching.tools
import ch.fram.medlineGeo.crunching.{LocalizedAffiliationPubmedIds, AffiliationHook}
import org.apache.spark.SparkContext
import org.apache.spark.sql._
import play.api.Logger
import scala.collection.mutable.ArrayBuffer
/**
*
* gett all the citation and extracti unique aff... |
Explain and rewrite the following Scala code: | package org.workcraft.plugins.petrify
import java.io.File
import org.workcraft.plugins.petri2.EditablePetriNet
import org.workcraft.plugins.petri2.PetriNetModel
import org.workcraft.plugins.petri2.PnFormatParser
import org.workcraft.plugins.petri2.VisualPetriNet
import org.workcraft.services.FileOpen
import org.workcra... |
Explain and rewrite the following Scala code: | class C {
val foo = 11
def bar = 12
val quux = 13
def baz = 14
class C { override def toString = "CC" }
object O { override def toString = "CO" }
override def toString = "an instance of class C"
}
class D extends C {
override val foo = 21
override def bar = 22
override def toString = "an instance o... |
Explain and rewrite the following Scala code: | package space.thedocking.infinitu.list
import org.junit.runner.RunWith
import org.specs2.matcher.ShouldMatchers
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import space.thedocking.infinitu.integer.IntegerValue
@RunWith(classOf[JUnitRunner])
class ListUniverseSpec extends Specification... |
Explain and rewrite the following Scala code: | package mesosphere.marathon
package core.readiness
import akka.actor.ActorSystem
import akka.stream.Materializer
import mesosphere.marathon.core.readiness.impl.ReadinessCheckExecutorImpl
/**
* Exposes everything necessary to execute readiness checks on tasks.
*
* A task might not be ready:
*
* * because it ... |
Explain and rewrite the following Scala code: | /*
Copyright 2014 Janek Bogucki
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 algorithms.greedy
import utils.SetInt
/**
* Created by yuJieShui on 2016/2/28.
*/
object Crush {
def readInts() = io.StdIn.readLine().split(" ").toList.map(_.toInt)
case class PlusInterval(begin: Int, end: Int, value: Int)
def sum(list: Seq[PlusInterval], rt: Int): Int = {
if (list.isEmpty) {... |
Explain and rewrite the following Scala code: | /*
* Copyright 2012 Vasily Shiyan
*
* 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 day6
import collection.immutable.BitSet
object Main extends App {
def foo = for {
x <- Some(3)
y <- Some("!")
} yield x.toString + y
println(s"$foo")
val bits = BitSet(1, 2, 3)
println(s"""${
for {
x <- bits
} yield x.toFloat
}""")
println(s"""${
for {
i <- List(1, 2, ... |
Explain and rewrite the following Scala code: | package controllers.admins
import scala.concurrent.Future
import play.api.mvc._
import play.api.data._
import play.api.data.Forms._
import play.api.data.validation.Constraints._
import play.api.i18n._
import play.api.libs.concurrent.Execution.Implicits._
import playground.form.Mappings._
import services._
import A... |
Explain and rewrite the following Scala code: | package com.github.xubo245.gcdss.avocado
import org.apache.spark.{SparkConf, SparkContext}
import org.bdgenomics.adam.rdd.ADAMContext
import org.bdgenomics.avocado.cli.{BiallelicGenotyper => BiallelicGenotypercli, DiscoverVariants, AvocadoMain}
/**
* Created by xubo on 2017/4/9.
*/
object DiscoverVariant {
def ... |
Explain and rewrite the following Scala code: | // Copyright (C) 2011-2012 the original author or authors.
// 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.
// You ... |
Explain and rewrite the following Scala code: | /*
*************************************************************************************
* Copyright 2011 Normation SAS
*************************************************************************************
*
* This file is part of Rudder.
*
* Rudder is free software: you can redistribute it and/or modify
* it under the... |
Explain and rewrite the following Scala code: | package com.twitter.bijection
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.Checkers
/**
* @author
* Mansur Ashraf.
*/
trait CheckProperties extends AnyPropSpec with Checkers {
def property(testName: scala.Predef.String, testTags: org.scalatest.Tag*)(
testFun: org.scala... |
Explain and rewrite the following Scala code: | /*******************************************************************************
* Copyright 2010 Maxime Lévesque
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://... |
Explain and rewrite the following Scala code: | package models
import java.util.Date
import java.sql.{ Date => SqlDate }
import play.api.Play.current
import play.api.db.slick.Config.driver.simple._
import scala.slick.lifted.Tag
import java.sql.Timestamp
case class Page[A](items: Seq[A], page: Int, offset: Long, total: Long) {
lazy val prev = Option(page - 1).fil... |
Explain and rewrite the following Scala code: | package com.arcusys.valamis.slide.service.lti
import com.arcusys.valamis.slide.service.lti.model.LTIData
import scala.concurrent.Future
trait LTIDataService {
def get(uuid: String): Future[Option[LTIData]]
def add(data: LTIData): Future[Unit]
def delete(uuid: String): Future[Int]
}
|
Explain and rewrite the following Scala code: | package com.wavesplatform.transaction.serialization.impl
import java.nio.ByteBuffer
import com.google.common.primitives.{Bytes, Longs}
import com.wavesplatform.serialization.ByteBufferOps
import com.wavesplatform.transaction.Asset.Waves
import com.wavesplatform.transaction.lease.LeaseTransaction
import com.wavesplatf... |
Explain and rewrite the following Scala code: | package com.seanshubin.builder.domain
import java.nio.file.Path
case class ProcessInput(command: Seq[String],
directory: Path,
environment: Map[String, String]) {
def addCommandPrefix(commandPrefix: Seq[String]): ProcessInput = {
copy(command = commandPrefix ++ co... |
Explain and rewrite the following Scala code: | object PythagoreanTriplet {
type Triple = (Int, Int, Int)
def isPythagorean(triple: Triple): Boolean = {
val (_a, _b, _c) = triple
val Seq(a, b, c) = Seq(_a, _b, _c).sorted
(a * a) + (b * b) == c * c
}
def pythagoreanTriplets(from: Int, to: Int): Seq[Triple] = for {
a <- from to to
b <- a... |
Explain and rewrite the following Scala code: | package part3testing
import akka.actor.{Actor, ActorSystem, Props}
import akka.testkit.{ImplicitSender, TestKit}
import org.scalatest.{BeforeAndAfterAll, WordSpecLike}
import scala.concurrent.duration._
import scala.util.Random
class BasicSpec extends TestKit(ActorSystem("BasicSpec"))
with ImplicitSender
with Wo... |
Explain and rewrite the following Scala code: | /*
* Copyright 2016 Dennis Vriend
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed t... |
Explain and rewrite the following Scala code: | /*
# Copyright 2016 Georges Lipka
#
# 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 latis.ops.filter
import latis.dm.Text
import latis.ops.OperationFactory
/**
* Select values of 'name' that contain 'value'.
*/
class StringContains(name: String, value: String) extends Selection(name, "=~", value) {
override def applyToText(text: Text): Option[Text] = {
if (text.hasName(vname)) tex... |
Explain and rewrite the following Scala code: | package reactivemongo.api
import scala.util.Try
import scala.concurrent.{ ExecutionContext, Future, Promise }
import scala.concurrent.duration.{ FiniteDuration, SECONDS }
import scala.collection.immutable.ListSet
import akka.util.Timeout
import akka.actor.ActorRef
import reactivemongo.io.netty.channel.{ ChannelId,... |
Explain and rewrite the following Scala code: | package org.flowpaint.input
import java.awt.event._
import java.lang.reflect.InvocationTargetException
import java.util.ArrayList
import java.util.concurrent.{ArrayBlockingQueue, BlockingQueue}
import jpen._
import jpen.event.PenListener
import org.flowpaint.util.DataSample
import org.flowpaint.util.PerformanceTester.... |
Explain and rewrite the following Scala code: | /*******************************************************************************
* Copyright (c) 2019. Carl Minden
*
* 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 ... |
Explain and rewrite the following Scala code: | package helpers
import play.api.http._
import play.api.libs.json._
import play.api.mvc._
/**
* @author zepeng.li@gmail.com
*/
trait ImplicitWritableOfJsValue {
implicit def contentTypeOf_JsValue_WithCharset(implicit codec: Codec): ContentTypeOf[JsValue] = {
ContentTypeOf[JsValue](Some(ContentTypes.withCharse... |
Explain and rewrite the following Scala code: | package t1000678_5
object Loggable {
case class RunUnit(val id : Integer) {
class C {
def foo: Unit = {}
}
}
}
class Loggable |
Explain and rewrite the following Scala code: | package concrete
package constraint
package extension
import com.typesafe.scalalogging.LazyLogging
import mdd._
import java.util
import scala.collection.immutable
final class BDDRelation(val bdd: BDD) extends Relation with LazyLogging {
type Self2 = BDDRelation
lazy val lambda: BigInt = bdd.lambda()
// val off... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.dotty.lang.psi.types
import com.intellij.psi.PsiNamedElement
import org.jetbrains.plugins.scala.lang.psi.types._
/**
* @author adkozlov
*/
object ScTypePresentation extends org.jetbrains.plugins.scala.lang.psi.types.api.ScTypePresentation {
override implicit lazy val typeSystem = D... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2016-2019 Lightbend Inc. <https://www.lightbend.com>
*/
package com.lightbend.lagom.internal
import io.netty.channel.Channel
import io.netty.channel.ChannelFuture
import io.netty.channel.ChannelFutureListener
import io.netty.util.concurrent.GenericFutureListener
import io.netty.util.concurrent.{ ... |
Explain and rewrite the following Scala code: | package org.littlewings.javaee7.service
import javax.inject.Inject
import org.jboss.arquillian.container.test.api.Deployment
import org.jboss.arquillian.junit.Arquillian
import org.jboss.shrinkwrap.api.ShrinkWrap
import org.jboss.shrinkwrap.api.spec.WebArchive
import org.jboss.shrinkwrap.resolver.api.maven.Maven
imp... |
Explain and rewrite the following Scala code: | package io.toolsplus.atlassian.connect.play.services
import io.toolsplus.atlassian.connect.play.TestSpec
import io.toolsplus.atlassian.connect.play.api.models.{
AtlassianHost,
DefaultAtlassianHost
}
import io.toolsplus.atlassian.connect.play.api.models.Predefined.ClientKey
import io.toolsplus.atlassian.connect.pla... |
Explain and rewrite the following Scala code: | package org.jetbrains.bsp.protocol
import java.io.File
import java.net.URI
import ch.epfl.scala.bsp._
import com.intellij.openapi.diagnostic.Logger
import monix.eval.Task
import monix.execution.Scheduler
import org.jetbrains.bsp.{BspError, BspErrorMessage, BspException}
import org.jetbrains.bsp.BspUtil.IdeaLoggerOps
... |
Explain and rewrite the following Scala code: | package spotlight.publish
import java.net.{ InetSocketAddress, Socket }
import scala.annotation.tailrec
import scala.collection.immutable
import scala.concurrent.duration._
import scala.concurrent.{ Await, Future }
import scala.util.{ Failure, Success, Try }
import akka.actor._
import akka.agent.Agent
import akka.dis... |
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2009-2011 the original author or authors.
* See the notice.md file distributed with this work for additional
* information regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Yo... |
Explain and rewrite the following Scala code: | package com.wavesplatform.network
import java.net.{InetSocketAddress, SocketAddress}
case class PeerInfo(remoteAddress: SocketAddress,
declaredAddress: Option[InetSocketAddress],
applicationName: String,
applicationVersion: (Int, Int, Int),
... |
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.rabbitonweb.nnspc
/**
P08 (**) Eliminate consecutive duplicates of list elements.
If a list contains repeated elements they should be replaced with a single copy of the element.
The order of the elements should not be changed.
Example:
scala> compress(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, '... |
Explain and rewrite the following Scala code: | /*
* Copyright 2012-2013 Stephane Godbillon (@sgodbillon) and Zenexity
*
* 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 req... |
Explain and rewrite the following Scala code: | class ScalaClient_1 {
def foo() = {
(null: A).f()
(null: B1).f()
(null: B2).f()
(null: B3).f()
(null: B4).f()
}
}
|
Explain and rewrite the following Scala code: | package net.ruippeixotog.scalascraper.model
/** A representation of a HTML DOM element.
*
* Elements can be obtained by obtaining [[Document]] instances (for example, through a
* [[net.ruippeixotog.scalascraper.browser.Browser]]) and using one of its several methods. They provide several
* methods for traversi... |
Explain and rewrite the following Scala code: | /*
* Copyright 2013 David Savage
*
* 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 views.html
package account
import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import controllers.routes
object twoFactor {
import trans.tfa._
private val qrCode = raw(
"""<div style="width: 276px; height: 276px; padding: 10px; background: white; ... |
Explain and rewrite the following Scala code: | package org.coursera.naptime.ari.graphql.schema
import com.linkedin.data.DataMap
import com.linkedin.data.schema.RecordDataSchema
import org.coursera.naptime.ari.graphql.SangriaGraphQlContext
import sangria.schema.Field
import sangria.schema.ObjectType
import sangria.schema.StringType
import scala.collection.JavaConv... |
Explain and rewrite the following Scala code: | package com.twitter.finagle.buoyant.h2
package service
import com.twitter.finagle.buoyant.h2.service.H2ReqRepFrame.{FinalFrame, RepAndFrame}
import com.twitter.util.{Return, Throw, Try}
case class H2ReqRep(request: Request, response: Try[Response])
object H2ReqRep {
@inline def apply(req: Request, rep: Response): H... |
Explain and rewrite the following Scala code: | package com.sprayed.chat.utils
import slick.driver.PostgresDriver.simple._
import scala.slick.jdbc.meta.MTable
import com.sprayed.chat.{ Configs => C }
trait PostgresSupport {
def db = Database.forURL(
url = s"jdbc:postgresql://${C.pgHost}:${C.pgPort}/${C.pgDBName}",
driver = C.pgDriver
)
implicit... |
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: | /*
* 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: | /*
* 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 io.hydrosphere.mist.master
import akka.actor.ActorSystem
import akka.testkit.{TestProbe, TestKit}
import io.hydrosphere.mist.Messages.JobMessages._
import io.hydrosphere.mist.Messages.StatusMessages.{QueuedEvent, CanceledEvent}
import io.hydrosphere.mist.Messages.WorkerMessages.WorkerUp
import io.hydrosphere.m... |
Explain and rewrite the following Scala code: | package com.outr.nextui.browser
import com.outr.nextui.ImageView
import com.outr.nextui.model.Image
import org.scalajs.dom.Event
import org.scalajs.dom.raw.HTMLImageElement
class ScalaJSImageView(val component: ImageView) extends ScalaJSComponent {
override val impl: HTMLImageElement = create[HTMLImageElement]("img... |
Explain and rewrite the following Scala code: | package tests
import scala.concurrent.{ Await, ExecutionContext }
import scala.concurrent.duration._
import reactivemongo.api.{
AsyncDriver,
CrAuthentication,
DefaultDB,
FailoverStrategy,
MongoDriver,
MongoConnection,
MongoConnectionOptions,
X509Authentication
}
object Common extends CommonAuth {
v... |
Explain and rewrite the following Scala code: | package filters
import javax.inject._
import scala.concurrent.{ExecutionContext, Future}
import akka.stream.Materializer
import play.api.mvc._
import play.Logger
/**
* This is a simple filter that adds a header to all requests. It's
* added to the application's list of filters by the
* [[ExampleFilter]] class.
... |
Explain and rewrite the following Scala code: | package mesosphere.marathon.health
import java.lang.{ Integer => JInt }
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import mesosphere.marathon.Protos
import mesosphere.marathon.Protos.HealthCheckDefinition.Protocol
import mesosphere.marathon.api.validation.FieldConstraints._
import mesosphere.maratho... |
Explain and rewrite the following Scala code: | def mapF[B](f: A => B): Optioon[B] =
fold(Noone, f andThen Soome.apply)
|
Explain and rewrite the following Scala code: | /*
* Copyright 2012 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 t... |
Explain and rewrite the following Scala code: | /*
* Copyright 2015 Otto (GmbH & Co KG)
*
* 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 doobie.contrib.h2
import doobie.contrib.h2.h2types._
import doobie.imports._
import java.net.InetAddress
import java.util.UUID
import java.util.concurrent.atomic.AtomicInteger
import org.specs2.mutable.Specification
import scalaz.concurrent.Task
import scalaz.{ Maybe, \\/- }
// Establish that we can read v... |
Explain and rewrite the following Scala code: | package net.fwbrasil.activate.statement.mass
import net.fwbrasil.activate.statement.Where
import net.fwbrasil.activate.statement.From
import net.fwbrasil.activate.statement.StatementSelectValue
import net.fwbrasil.activate.statement.query.Query
import net.fwbrasil.activate.entity.BaseEntity
import net.fwbrasil.activat... |
Explain and rewrite the following Scala code: | package gapt.examples.sequence
import gapt.expr._
import gapt.expr.formula.fol.Utils
import gapt.proofs.Sequent
import gapt.proofs.gaptic.Proof
import gapt.proofs.gaptic.chain
import gapt.proofs.gaptic.prop
import gapt.proofs.gaptic.repeat
import gapt.proofs.lk.LKProof
/**
* Constructs cut-free FOL LK proofs of the ... |
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 jsa.model
import net.liftweb.http.SessionVar
import scalaz.{NonEmptyList, Validation}
trait Login {
object UserSession extends SessionVar[Option[User]](None)
def user: Option[User] = UserSession.get
def isLoggedIn = UserSession.isDefined
def login(login: String, pass: String): Validation[NonEmptyList... |
Explain and rewrite the following Scala code: | package imperial.mocks
import imperial.measures.Meter
class MockMeter extends Meter {
var count: Long = 0L
def mark(): Unit = count += 1
def mark(delta: Long): Unit = count += delta
def meanRate: Double = ???
def oneMinuteRate: Double = ???
def fiveMinuteRate: Double = ???
def fifteenMinuteRate: Doub... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2014 - 2019 Dennis Vriend <https://github.com/dnvriend>
* Copyright (C) 2019 - 2021 Lightbend Inc. <https://www.lightbend.com>
*/
package akka.persistence.jdbc.query
import akka.Done
import akka.persistence.query.{ EventEnvelope, NoOffset, Sequence }
import akka.pattern.ask
import akka.persisten... |
Explain and rewrite the following Scala code: | package com.phasmid.laScala.values
/**
* Appendix to Rational class: only for Scala 2.11
*
* @author scalaprof
*/
object Rational_Cross {
def isExactDouble[N: FiniteIntegral](r: Rational[N]): Boolean = r.toBigDecimal.map(_.isExactDouble) getOrElse false
} |
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: | package io.rout
import java.util.UUID
import algebra.Eq
import cats.Show
import com.twitter.io.Buf
import com.twitter.util.{Return, Throw, Try}
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
/**
* Type class instances for non-Finch types.
*/
@RunWith(classOf[JUnitRunner])
trait MissingInsta... |
Explain and rewrite the following Scala code: | package nars.main
import java.util.ArrayList
import javax.swing.SwingUtilities
import nars.storage._
import nars.io._
import nars.gui._
import nars.entity._
import scala.reflect.{BeanProperty, BooleanBeanProperty}
//remove if not needed
import scala.collection.JavaConversions._
/**
* A NARS Reasoner has its memory, ... |
Explain and rewrite the following Scala code: | import scala.reflect.runtime.universe._
import scala.reflect.ClassTag
case class R(
sales : Int,
name : String
)
class Foo{
import Test._
def foo = {
val expectedType = implicitly[TypeTag[R]]
val classTag = implicitly[ClassTag[R]]
val cl = classTag.runtimeClass.getClassLoader
val cm = runtimeMirror(cl)
... |
Explain and rewrite the following Scala code: | object A {
def get: Int = 1
}
|
Explain and rewrite the following Scala code: | /**
* Created by jak on 6/9/16.
*/
object ExampleApp extends App{
println("Hello App World")
}
|
Explain and rewrite the following Scala code: | trait T {
def f = {}
}
val v = new T {}
println(v./* line: 2 */f)
|
Explain and rewrite the following Scala code: | package scala.reflect.quasiquotes
import org.scalacheck._, Prop._, Gen._, Arbitrary._
object ErrorProps extends QuasiquoteProperties("errors") {
property("can't extract two .. rankinalities in a row") = fails(
"Can't extract with .. here",
"""
val xs = List(q"x1", q"x2")
val q"f(..$xs1, ..$xs2)"... |
Explain and rewrite the following Scala code: | /*
* Copyright 2021 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or a... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) <2015-2016>, see CONTRIBUTORS
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list... |
Explain and rewrite the following Scala code: | package com.pwootage.metroidprime.formats.mlvl
import com.pwootage.metroidprime.formats.BinarySerializable
import com.pwootage.metroidprime.formats.io.PrimeDataFile
class MLVL extends BinarySerializable {
val header = new Header
var memoryRelays = Array[MemoryRelay]()
var areaUnk: Int = -1
var area... |
Explain and rewrite the following Scala code: | import scala.reflect.runtime.universe._
import scala.tools.reflect.ToolBox
import scala.tools.reflect.Eval
trait O { trait I }
object A extends O {
val impl = new I {}
}
object Test extends App {
val code = reify {
val v: A.I = A.impl
v
}
println(showRaw(code.tree))
val v: A.I = code.eval
}
|
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2015, Michael Lewis
* 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 conditio... |
Explain and rewrite the following Scala code: | package org.dbpedia.spotlight.util
import breeze.linalg.{DenseVector, Transpose}
import breeze.numerics.sqrt
import org.apache.commons.math.util.FastMath
/**
* @author Joachim Daiber
*/
object MathUtil {
val LOGZERO = Double.NegativeInfinity
def isLogZero(x: Double): Boolean = x.isNegInfinity
def exp(x: D... |
Explain and rewrite the following Scala code: | package com.twitter.finagle.serverset2.client.apache
import com.twitter.conversions.time._
import com.twitter.finagle.serverset2.client._
import com.twitter.finagle.stats.InMemoryStatsReceiver
import com.twitter.io.Buf
import com.twitter.util.{Return, Await}
import java.util.concurrent.ExecutionException
import org.ap... |
Explain and rewrite the following Scala code: | package com.eharmony.aloha.dataset
import com.eharmony.aloha.dataset.density.{Dense, Sparse}
import com.eharmony.aloha.dataset.json.CovariateJson
import com.eharmony.aloha.reflect.RefInfo
import com.eharmony.aloha.semantics.compiled.CompiledSemantics
import com.eharmony.aloha.semantics.func.GenAggFunc
import scala.co... |
Explain and rewrite the following Scala code: | package utils.date
import org.joda.time.LocalDate
import org.joda.time.format.DateTimeFormat
import scala.util.Try
trait DateTimeFormatterPattern {
lazy val dateTimePattern = "yyyy-MM-dd'T'HH:mm"
lazy val datePattern = "yyyy-MM-dd"
lazy val timePattern = "HH:mm:ss"
lazy val dateTimeFormatter = DateTimeFormat... |
Explain and rewrite the following Scala code: | /**
* (c) Copyright 2014 WibiData, Inc.
*
* See the NOTICE 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.
* You may obtain a copy of... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2012 Romain Reuillon
*
* 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 program is di... |
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: | /* - Coeus web framework -------------------------
*
* Licensed under the Apache License, Version 2.0.
*
* Author: Spiros Tzavellas
*/
package com.tzavellas.coeus.mvc
package view
/**
* A <i>null-object</i> implementation for {@code View}.
*/
object NullView extends View {
/** The content-type is null. */
... |
Explain and rewrite the following Scala code: | package org.embulk.input.dynamodb.testutil
import com.amazonaws.auth.{AWSStaticCredentialsProvider, BasicAWSCredentials}
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration
import com.amazonaws.services.dynamodbv2.{
AmazonDynamoDB,
AmazonDynamoDBClientBuilder
}
import org.embulk.config.{Conf... |
Explain and rewrite the following Scala code: | import sbt._
object Dependencies {
lazy val playVersion = "2.5.10"
}
|
Explain and rewrite the following Scala code: | package org.scalawag.pickaxe
import org.scalatest.matchers.ShouldMatchers
import org.scalatest.FunSuite
import scala.xml.{NodeSeq,Elem}
class XmlPickaxeTest extends FunSuite with ShouldMatchers {
private val xml =
<root id="1234">
<booleans>
<one>true</one>
<two>false</two>
</boolea... |
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 java.util
import scalajs.js
import scala.annotation.tailrec
import scala.reflect.ClassTag
import scala.collection.immutable
object Arrays {
@inline
private final implicit def naturalOrdering[T <: AnyRef]: Ordering[T] = {
new Ordering[T] {
def compare(x: T, y: T): Int = x.asInstanceOf[Compara... |
Explain and rewrite the following Scala code: | /**
* Created by vernonzheng on 15/1/20.
*/
/**
* 编写函数计算x^n, 其中n为整数。
*/
def getPower(x:Double, n:Int):Double = {
if (n == 0 ) 1
else if ( n>0 && n % 2 != 0 ) x * getPower(x, n-1)
else if (n >0 && n % 2 == 0 ) getPower (x, n/2) * getPower (x, n/2)
else 1/getPower( x, -n)
} |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2016 Christopher Batey and Dogan Narinc
*
* 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 appli... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.