instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
Explain and rewrite the following Scala code: | package com.andre_cruz.concurrent
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.{Matchers, WordSpecLike}
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
class RichFutureTest extends WordSpecLike with Matchers with ScalaFutures {
import com.andre_cruz.c... |
Explain and rewrite the following Scala code: | import test._
import org.specs2.mutable.Specification
class SpecificPrimitivesSpec extends Specification {
"A case class with an `Int` field" should {
"deserialize correctly" in {
val record1 = AvroTypeProviderTest00(1)
val record2 = AvroTypeProviderTest00(2)
val records = List(record1, record... |
Explain and rewrite the following Scala code: | package dst.amqp
import akka.event.Logging
import akka.actor.ActorContext
import akka.actor.ActorRef
import akka.actor.TypedActor
import com.rabbitmq.client.AMQP
import com.rabbitmq.client.Consumer
import com.rabbitmq.client.Envelope
import com.rabbitmq.client.ShutdownSignalException
trait ActorConsumer extends Co... |
Explain and rewrite the following Scala code: | package net.sansa_stack.rdf.spark.io
import java.net.URI
import java.nio.file.{Files, Paths}
import java.util.UUID
import com.google.common.base.Predicates
import com.google.common.collect.Iterators
import net.sansa_stack.rdf.benchmark.io.ReadableByteChannelFromIterator
import net.sansa_stack.rdf.common.io.riot.error... |
Explain and rewrite the following Scala code: | package com.eharmony.aloha.semantics.compiled.plugin.avro
import com.eharmony.aloha.reflect.RefInfo
import com.eharmony.aloha.semantics.compiled.plugin.schemabased.schema.Schema.FieldRetrievalError
import com.eharmony.aloha.semantics.compiled.plugin.schemabased.schema._
import org.apache.avro
import org.apache.avro.Sc... |
Explain and rewrite the following Scala code: | package utils.remote.amazon
import org.specs2.mutable._
import org.specs2.runner._
import org.junit.runner._
import play.api.test._
import play.api.test.Helpers._
import org.specs2.runner.JUnitRunner
import org.junit.runner.RunWith
import play.api.Logger
/**
* @author alari (name.alari@gmail.com)
* @since 10.10.1... |
Explain and rewrite the following Scala code: | /*
* Copyright 2011-2018 GatlingCorp (http://gatling.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.org/licenses/LICENSE-2.0
*
* Unless required by applic... |
Explain and rewrite the following Scala code: | package au.com.dius.pact.server
import _root_.unfiltered.netty.{ReceivedMessage, ServerErrorResponse, cycle}
import _root_.unfiltered.request.HttpRequest
import _root_.unfiltered.response.ResponseFunction
import au.com.dius.pact.model._
import au.com.dius.pact.consumer._
import org.json4s._
import org.json4s.JsonDSL._... |
Explain and rewrite the following Scala code: | /*
* Scala.js (https://www.scala-js.org/)
*
* Copyright EPFL.
*
* Licensed under Apache License 2.0
* (https://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/
package org.scalajs.linker.backend.emitter
im... |
Explain and rewrite the following Scala code: | /*
* Copyright 2017 Michael Stringer
*
* 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 lore.compiler.types
import scala.util.hashing.MurmurHash3
/**
* A type that describes immutable lists. Lists are covariant.
*/
case class ListType(element: Type) extends Type {
override val hashCode: Int = {
// We use a product hash here to differentiate the hash code from type hashes.
MurmurHas... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2010 Lalit Pant <pant.lalit@gmail.com>
*
* The contents of this file are subject to the GNU General Public License
* Version 3 (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.gnu.org/copyleft/gpl.html
*
*... |
Explain and rewrite the following Scala code: | package breeze.optimize.flow
import org.scalatest._;
import org.scalatest.junit._;
import org.scalatest.prop._;
import org.scalacheck._;
import org.junit.runner.RunWith
/**
*
* @author dlwh
*/
@RunWith(classOf[JUnitRunner])
class LPMaxFlowTest extends FunSuite {
val g = new FlowGraph[Int] {
def source... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2013 Daniel Krzywicki <daniel.krzywicki@agh.edu.pl>
*
* 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
... |
Explain and rewrite the following Scala code: | package org.bowlerframework.exception
/**
* The Exception equivalent of HTTP 404 - Not Found
*/
class NotFoundException extends HttpException(404) |
Explain and rewrite the following Scala code: | import Q._
class Bop(var workUnit: WorkUnit) {
def addStages(stageBuilder: Stage.Builder): Unit = {
val builder = workUnit.toBuilder
()
}
}
|
Explain and rewrite the following Scala code: | package ch.ninecode.model
import com.esotericsoftware.kryo.Kryo
import com.esotericsoftware.kryo.Serializer
import com.esotericsoftware.kryo.io.Input
import com.esotericsoftware.kryo.io.Output
import org.apache.spark.sql.Row
import ch.ninecode.cim.CIMClassInfo
import ch.ninecode.cim.CIMContext
import ch.ninecode.cim.... |
Explain and rewrite the following Scala code: | package scala.macros.internal
package plugins.scalac
package parser
import scala.collection.mutable
import scala.reflect.internal.util.BatchSourceFile
import scala.tools.nsc.{Global => NscGlobal, SubComponent, Settings => NscSettings}
import scala.tools.nsc.interpreter.{ReplGlobal => NscReplGlobal, _}
import scala.mac... |
Explain and rewrite the following Scala code: | package lila.insight
import reactivemongo.api.collections.bson.BSONBatchCommands.AggregationFramework._
import reactivemongo.bson._
object AggregationClusters {
def apply[X](question: Question[X], res: AggregationResult): List[Cluster[X]] =
postSort(question) {
if (Metric isStacked question.metric) stack... |
Explain and rewrite the following Scala code: | package gapt.proofs.resolution
import gapt.expr._
import gapt.expr.formula.Eq
import gapt.expr.formula.fol.FOLAtom
import gapt.expr.formula.fol.FOLAtomConst
import gapt.expr.formula.fol.FOLConst
import gapt.expr.formula.fol.FOLVar
import gapt.expr.subst.Substitution
import gapt.logic.clauseSubsumption
import gapt.proo... |
Explain and rewrite the following Scala code: | package org.apache.spark.asyspark.core.messages.master
import akka.actor.ActorRef
/**
* Created by wjf on 16-9-22.
*/
private[asyspark] case class RegisterServer(server: ActorRef)
|
Explain and rewrite the following Scala code: | import _root_.runtime.RosalindSolution
import collection.mutable
import math.ceil
object MajorityElement extends RosalindSolution {
def problem_name: String = "maj"
def get_answer(input_lines: Iterator[String]): String = {
// Ignore metadata
val metadata = input_lines.next_as_array()
val array_leng... |
Explain and rewrite the following Scala code: | package us.msea.vaderz.js
import us.msea.vaderz.shared.framework._
import org.scalajs.dom
import org.scalajs.dom.html
class JSCanvas(val _width : Int = 800, val _height : Int = 600) extends Canvas {
var _eventHandler : ProcessingApiAdapter = null
val canvas = dom.document.getElementById("canvas").asInstance... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2015, streamdrill UG (haftungsbeschränkt)
* 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, th... |
Explain and rewrite the following Scala code: | package mesosphere.mesos.simulation
import java.util.UUID
import akka.actor.{ Actor, ActorRef, Cancellable, Props }
import akka.event.LoggingReceive
import mesosphere.marathon.stream.Implicits._
import mesosphere.mesos.simulation.DriverActor._
import mesosphere.mesos.simulation.SchedulerActor.ResourceOffers
import 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: | package com.paypal
package object genio{
type SchemaKey = String
type Parameter = Schema
}
|
Explain and rewrite the following Scala code: | package play.api.data.mapping
import scala.annotation.implicitNotFound
import scala.language.implicitConversions
@implicitNotFound("No Format found for types ${IR},${IW}, ${O}. Try to implement an implicit Format[${IR}, ${IW}, ${O}].")
trait Format[IR, IW, O] extends RuleLike[IR, O] with WriteLike[O, IW]
/**
* Defa... |
Explain and rewrite the following Scala code: | /* __ *\\
** ________ ___ / / ___ __ ____ Scala.js tools **
** / __/ __// _ | / / / _ | __ / // __/ (c) 2013-2014, LAMP/EPFL **
** __\\ \\/ /__/ __ |/ /__/ __ |/_// /_\\ \\ http://scala-js.org/ **
** /____/\\___/... |
Explain and rewrite the following Scala code: | package se.culvertsoft.mgen.compiler.util
object MeasureTime {
def apply[A](dbgString: String)(f: => A): A = {
val t0 = System.nanoTime() / 1e9
val out = f
val t1 = System.nanoTime() / 1e9
val dt = t1 - t0
println(s"MeasureTime [$dbgString]: $dt s")
out
}
} |
Explain and rewrite the following Scala code: | package org.gDanix.podapp_ng_server.controllers.v0
import play.api.mvc.Action
import org.gDanix.podapp_ng_server.controllers.v0.common.{CommonResponses, ExecutionContext, Sessions}
trait Logout extends CommonResponses with ExecutionContext with Sessions {
val logoutSuccessfulResponse = operationDone
def lo... |
Explain and rewrite the following Scala code: | package collins.models
import org.squeryl.PrimitiveTypeMode._
import org.squeryl.annotations.Column
import org.squeryl.dsl.ast.LogicalBoolean
import play.api.libs.json.Json
import collins.models.asset.AssetView
import collins.models.cache.Cache
import collins.models.shared.AddressPool
import collins.models.shared.Ip... |
Explain and rewrite the following Scala code: | package core.provider
import akka.actor.{Actor, ActorRef, Cancellable, Props}
import core.CoreMessage._
import core.clientView.{ClientViewActor, ClientViewRef}
import core.host.{Host, HostObserver, HostPool}
import core.spatial.Zone
import core.{clientView, observerPattern}
import play.api.libs.json.{JsArray, Json}
i... |
Explain and rewrite the following Scala code: | package com.eugene.impatience_scala
import java.io._
import scala.collection.mutable.ArrayBuffer
import scala.io.Source
/**
* Created by eugene on 16/3/8.
*/
object Chap9 {
def main(args: Array[String]) {
// t1()
// t2()
// t3()
// t5()
// t9()
// t10()
}
def... |
Explain and rewrite the following Scala code: | /*
* Copyright 2016 Carlo Micieli
*
* 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: | /////////////////////////////////////////////////////
// Речевой портал //
// © ООО «Праймтолк», 2011-2013 //
// Авторы: Жижелев А.А., Нехаев А.Р., Попов П.А. //
// Все права принадлежат компании ООО «Праймтолк». //
//////////////////////////////////////////////////... |
Explain and rewrite the following Scala code: | /* Copyright 2009-2021 EPFL, Lausanne */
package stainless
package transformers
import inox.transformers.TraverserOp
trait Traverser extends inox.transformers.Traverser {
val trees: ast.Trees
import trees._
override def traverse(e: Expr, env: Env): Unit = e match {
case MatchExpr(scrut, cases) =>
tr... |
Explain and rewrite the following Scala code: | package scorex.consensus
import scorex.block.{GenesisBlock, NxtGenesisBlock, QoraGenesisBlock}
import scorex.consensus.nxt.{NxtBlockGenerationData, NxtBlockGenerationDataParser, NxtBlockGenerationFunctions}
import scorex.consensus.qora.{QoraBlockGenerationData, QoraBlockGenerationDataParser, QoraBlockGenerationFunctio... |
Explain and rewrite the following Scala code: | package net.rrm.ehour.ui.manage.lock
import com.google.common.collect.Lists
import net.rrm.ehour.AbstractSpringWebAppSpec
import net.rrm.ehour.timesheet.service.TimesheetLockService
import net.rrm.ehour.user.service.UserService
import org.apache.wicket.Component
import org.apache.wicket.ajax.AjaxRequestTarget
import o... |
Explain and rewrite the following Scala code: | package com.github.mdr.mash.ns.http
import java.net.UnknownHostException
import java.nio.charset.StandardCharsets
import java.nio.file.Path
import com.github.mdr.mash.evaluator.EvaluatorException
import com.github.mdr.mash.evaluator.ToStringifier.stringify
import com.github.mdr.mash.ns.json.PrettyPrintFunction
import... |
Explain and rewrite the following Scala code: | import sbt._
import Keys._
object Dependencies {
lazy val jodaTime = Seq(
"joda-time" % "joda-time" % "2.6",
"org.joda" % "joda-convert" % "1.7"
)
lazy val jackson = Seq(
// TODO 2.5 has breaking API changes
"com.fasterxml.jackson.core" % "jackson-databind" % "2.3.5"
)
lazy val ... |
Explain and rewrite the following Scala code: | /*
* Copyright 2016 Actian Corporation
*
* 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: | /*
*************************************************************************************
* Copyright 2016 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.github.opengrabeso.formulafx
import javax.swing.KeyStroke
import scala.swing.Action
class ActionWithCode(name: String, code: => Unit) extends Action(name) {
def apply() = code
def this(name: String, code: => Unit, keyStroke: Option[KeyStroke]) = {
this(name, code)
accelerator = keyStroke
}... |
Explain and rewrite the following Scala code: | package org.scalajs.benchmark.tracer
trait App
|
Explain and rewrite the following Scala code: | package com.github.chengpohi.builder
import com.github.chengpohi.model.FieldSelector
/**
* secer
* Created by chengpohi on 3/19/16.
*/
object FieldSelectorBuilder {
val fieldSelector = FieldSelector("div", "div")
val fieldSelectors = List(FieldSelector("div1", "div1"), FieldSelector("div2", "div2"))
}
|
Explain and rewrite the following Scala code: | /*
* Copyright 2017 TWO SIGMA OPEN SOURCE, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable... |
Explain and rewrite the following Scala code: | /*
* This file is part of pelam-scala-csv
*
* Copyright © Peter Lamberg 2015 (pelam-scala-csv@pelam.fi)
*
* 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/... |
Explain and rewrite the following Scala code: | package com.equalinformation.poc.akka.scala.track1.tellaskforward
import akka.actor.{Actor, ActorLogging}
/**
* Created by bpupadhyaya on 2/12/16.
*/
class SampleTellActor extends Actor with ActorLogging {
def receive = {
case message: String => {
log.info("message received", message)
sender ! m... |
Explain and rewrite the following Scala code: | package im.actor.server.notifications
import scala.concurrent.{ Future, ExecutionContext }
import org.joda.time.DateTime
import slick.dbio.DBIO
import slick.driver.PostgresDriver.api._
import im.actor.server.models.PeerType
import im.actor.server.util.ContactsUtils
import im.actor.server.{ models, persist }
class U... |
Explain and rewrite the following Scala code: | /***********************************************************************
* Copyright (c) 2013-2022 Commonwealth Computer Research, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and... |
Explain and rewrite the following Scala code: | package org.squeryl.mssql
import org.squeryl.test._
import org.squeryl.adapters.MSSQLServer
import org.squeryl.framework.DBConnector
import org.squeryl.Session
trait MSSQL_Connection extends DBConnector{
def connectToDb() : Option[() => Session] = {
if(config.hasProps("mssql.connectionString")) {
... |
Explain and rewrite the following Scala code: | package models.messages.application
/**
* Created by basso on 10/04/15.
*
* The Application manager actor receives this message. One from each of the major
* sub-systems after they are initielised. After all the Ready messages are received,
* the application will be open to client connections
*/
case class Ready... |
Explain and rewrite the following Scala code: | package evogame.evolution.types
import evogame.evolution.{DNA, Organism}
case class Conway(state: Grid[Boolean], dna: DNA[Grid[Boolean]]) extends Organism[Grid[Boolean], Conway] {
def alive = true
def grow: Conway = {
val cells = Grid.range(state.size).map { case (x, y) =>
val nb = state.neighbors(x, y)... |
Explain and rewrite the following Scala code: | package game.server.engine
import akka.actor.{ActorRef, Actor}
import game.server.engine.PlayRoom.{PlayerAck, Join, PlayerUpdate}
class PlayRoom extends Actor {
var masterState = GameState.EmptyState
def receive = {
case Join(client, playerID, state) => join(client, playerID, state)
case PlayerU... |
Explain and rewrite the following Scala code: | /*
* Copyright 2017-2022 John Snow Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agr... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | /*
* Copyright 2015 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) 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 applic... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
Explain and rewrite the following Scala code: | package com.automatak.render.dnp3.objects.groups
import com.automatak.render.dnp3.objects.{ClassData, AnyVariation, ObjectGroup}
object Group60 extends ObjectGroup {
def objects = List(Group60Var1, Group60Var2, Group60Var3, Group60Var4)
def group: Byte = 60
def desc: String = "Class Data"
def isEventGroup: Bo... |
Explain and rewrite the following Scala code: | package org.sisioh.aws4s.cfn.model
import com.amazonaws.services.cloudformation.model.{ Parameter, UpdateStackRequest }
import org.sisioh.aws4s.PimpedType
import scala.collection.JavaConverters._
object UpdateStackRequestFactory {
def create(): UpdateStackRequest = new UpdateStackRequest()
}
class RichUpdateSta... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2009-2012 Lalit Pant <pant.lalit@gmail.com>
*
* The contents of this file are subject to the GNU General Public License
* Version 3 (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.gnu.org/copyleft/gpl.html
... |
Explain and rewrite the following Scala code: | /***********************************************************************
* Copyright (c) 2013-2022 Commonwealth Computer Research, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and... |
Explain and rewrite the following Scala code: | package org.broadinstitute.clio.transfer.model.gvcf
/** Expected extensions for files tracked by the gvcf index. */
object GvcfExtensions {
/** File extension for gvcfs. */
val GvcfExtension = ".g.vcf.gz"
/** File extension for gvcf indices. */
val IndexExtension = s"$GvcfExtension.tbi"
/** File extension... |
Explain and rewrite the following Scala code: | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 Thomas Denoréaz
*
* 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
*... |
Explain and rewrite the following Scala code: | package com.twitter.finagle.mysql
import com.twitter.finagle.mysql.transport.MysqlBufWriter
import java.util.logging.Logger
import language.implicitConversions
/**
* A value of type `A` can implicitly convert to a `Parameter` if an evidence `CanBeParameter[A]` is
* available in scope. This type is not to be instant... |
Explain and rewrite the following Scala code: | package com.lookout.borderpatrol
import com.twitter.finagle.Service
import com.twitter.finagle.http.{Request => FinagleRequest, Response => FinagleResponse}
import com.twitter.util.Future
import org.jboss.netty.handler.codec.http._
class TokenService extends Service[HttpRequest, FinagleResponse] {
def apply(request... |
Explain and rewrite the following Scala code: | package com.itszuvalex.itszulib.testing
import com.itszuvalex.itszulib.core.TileContainer
import net.minecraft.block.material.Material
import net.minecraft.tileentity.TileEntity
import net.minecraft.world.World
/**
* Created by Alex on 12.10.2015.
*/
class BlockTankTest extends TileContainer(Material.iron) {
over... |
Explain and rewrite the following Scala code: | //---------------------------------------------------------------------------
// Copyright 2006-2009
// Dan Roozemond, d.a.roozemond@tue.nl, (TU Eindhoven, Netherlands)
// Peter Horn, horn@math.uni-kassel.de (University Kassel, Germany)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// y... |
Explain and rewrite the following Scala code: | package dotty.tools.dotc
package transform
import TreeTransforms._
import core.Names.Name
import core.DenotTransformers._
import core.Denotations._
import core.SymDenotations._
import core.Contexts._
import core.Symbols._
import core.Types._
import core.Flags._
import core.Constants._
import core.StdNames._
import cor... |
Explain and rewrite the following Scala code: | package queries
import java.time.LocalDateTime
import datamodel.dataModel.Task
import datamodel.{Priority, dataModel}
import org.scalatest.{BeforeAndAfterAll, FunSpec, Matchers}
import queries._
import slick.driver.H2Driver.api._
import scala.concurrent._
import scala.concurrent.duration._
class QueriesSpec extends... |
Explain and rewrite the following Scala code: | /*
* Scala (https://www.scala-lang.org)
*
* Copyright EPFL and Lightbend, Inc.
*
* Licensed under Apache License 2.0
* (http://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/
package scala.async
package ru... |
Explain and rewrite the following Scala code: | /*
* Copyright 2013 http4s.org
*
* 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: | import com.couchbase.client.scala.json.JsonObject
import com.couchbase.spark.kv.{Get, Upsert}
import org.apache.spark.sql.SparkSession
object WorkingWithRDDs {
def main(args: Array[String]): Unit = {
// tag::context[]
val spark = SparkSession
.builder()
.master("local[*]")
.appName("Worki... |
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 org.broadinstitute.dsde.firecloud.webservice
import java.text.SimpleDateFormat
import akka.http.scaladsl.client.RequestBuilding
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server.{Directives, Route}
import org.broadinst... |
Explain and rewrite the following Scala code: | /* __ *\\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
** __\\ \\/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\\___/_/... |
Explain and rewrite the following Scala code: | package solve
object Problem32 extends App{
def list2i(l:List[Int]):Int = l.mkString("").toInt
println(
Problem24.gen_permutation(Range(1, 9 + 1).toList).foldLeft(Set[Int]()){(b, v) =>
Range(1, 4+1).flatMap{i1 =>
Range(1, 4+1).map{i2 =>
val (v1, rest) = v.spli... |
Explain and rewrite the following Scala code: | package nodes.learning
import breeze.linalg._
import breeze.numerics._
import breeze.stats._
import breeze.stats.distributions.{Gaussian, ThreadLocalRandomGenerator, RandBasis}
import com.github.fommil.netlib.LAPACK._
import edu.berkeley.cs.amplab.mlmatrix.util.QRUtils
import org.apache.commons.math3.random.MersenneTw... |
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.gu.mobile.notifications.client.models
import org.specs2.mutable.Specification
class LinkTest extends Specification {
"toString" should {
"return the url if the Link is of type ExternalLink" in {
val link = ExternalLink("myLink")
link.toString mustEqual "myLink"
}
"return the co... |
Explain and rewrite the following Scala code: | package com.github.crockeo.booler
object Main {
// "symmetry" program mode.
def symmetry(e: Expression): Unit = {
println("Evaluating " + Eval.sPrettyPrint(e))
for (x <- 0.to(Eval.countVars(e)))
println(" Symmetric at " + x + ": " + (if (Eval.isSymmetric(e, x)) "Y"
... |
Explain and rewrite the following Scala code: | package controllers.alertwatchernm
import javax.inject._
import play.api._
import play.api.mvc._
import play.api.data.Form
import play.api.data.Forms._
import play.api.data._
import models.alertwatchernm.Alert
import play.api.i18n.Messages
import play.api.i18n.I18nSupport
import play.api.i18n.MessagesApi
import servic... |
Explain and rewrite the following Scala code: | package mevolutrix.Interface
import akka.actor.ActorRef
import akka.pattern._
import akka.util._
import scala.concurrent.duration._
import scala.concurrent.Await
import scala.concurrent.duration.Duration
case class SME_PostRequest(funcName:String,params:Map[String,String],postData:String)
case class SME_GetRequest(fun... |
Explain and rewrite the following Scala code: | package org.substeps.report
import java.{io, util}
import java.io.{BufferedWriter, File, FileNotFoundException, IOException}
import java.net.{JarURLConnection, URISyntaxException, URL}
import java.nio.charset.Charset
import java.time.format.DateTimeFormatter
import java.time.{Instant, LocalDateTime, ZoneId}
import jav... |
Explain and rewrite the following Scala code: | package org.dataalgorithms.chap10.scala
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
/**
* MovieRecommendations: very basic movie recommnedation...
*
* @author Gaurav Bhardwaj (gauravbhardwajemail@gmail.com)
*
* @editor Mahmoud Parsian (mahmoud.parsian@yahoo.com)
*
*/
object MovieRec... |
Explain and rewrite the following Scala code: | /*
* GenWindow.scala
* (FScape)
*
* Copyright (c) 2001-2022 Hanns Holger Rutz. All rights reserved.
*
* This software is published under the GNU Affero General Public License v3+
*
*
* For further information, please contact Hanns Holger Rutz at
* contact@sciss.de
*/
package de.sciss.fscape
package st... |
Explain and rewrite the following Scala code: | package com.adendamedia.salad.api
import scala.language.implicitConversions
import scala.util.{Failure, Success, Try}
object ImplicitTryConverters {
implicit def TryJavaBooleanToTryScalaBoolean(in: Try[java.lang.Boolean])
: Try[Boolean] =
in.map(_ == true)
implicit def TryJavaLongToTryScalaLong(in: Try[ja... |
Explain and rewrite the following Scala code: | /*
* Scala (https://www.scala-lang.org)
*
* Copyright EPFL and Lightbend, Inc.
*
* Licensed under Apache License 2.0
* (http://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/
package scala.tools.nsc
packag... |
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: | /*
* Copyright 2009-2010 the original author or 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 appl... |
Explain and rewrite the following Scala code: | import sbt._
import sbt.Keys._
import spray.revolver.RevolverPlugin.Revolver
object LoopMain {
lazy val loopMain = inputKey[spray.revolver.AppProcess]("Call ~loopMain a.b.Class to make sbt revolve a main") := {
import Revolver._
import spray.revolver.Actions._
val main :: args = sbt.complete.Parsers.spac... |
Explain and rewrite the following Scala code: | package mesosphere.marathon.event
import mesosphere.marathon.health.HealthCheck
import mesosphere.marathon.upgrade.{ DeploymentPlan, DeploymentStep }
import org.rogach.scallop.ScallopConf
import com.google.inject.{ Inject, Singleton, Provides, AbstractModule }
import akka.event.EventStream
import javax.inject.Named
im... |
Explain and rewrite the following Scala code: | /*
* Copyright 2016 Coursera 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 (c) 2013-2017 Commonwealth Computer Research, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and... |
Explain and rewrite the following Scala code: | package scala.collection.mutable
import org.scalacheck._
import org.scalacheck.Prop._
import scala.collection.immutable
object HashMapProperties extends Properties("mutable.HashMap") {
override def overrideParameters(p: Test.Parameters): Test.Parameters =
p.withMinSuccessfulTests(500)
.withInitialSeed(4... |
Explain and rewrite the following Scala code: | package scala.slick.jdbc
import java.sql.PreparedStatement
import scala.slick.util.CloseableIterator
/**
* An invoker which executes an SQL statement.
*/
abstract class StatementInvoker[-P, +R] extends Invoker[P, R] { self =>
protected def getStatement: String
protected def setParam(param: P, st: PreparedStat... |
Explain and rewrite the following Scala code: | package IFDS
import scala.collection.mutable.ListBuffer
class SimpleIFDSProblem(
val methodToStartPoints: Map[Method, Set[Node]],
val normalEdges: Set[NormalEdge],
val returnEdges: Set[ReturnEdge],
val callEdges: Set[CallEdge],
val callToReturnEdges: Set[CallToReturnEdge],
val stmtToMethod: Map[Node, Meth... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.