instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
package org.littlewings.infinispan.interceptor import org.infinispan.commands.write.PutKeyValueCommand import org.infinispan.context.InvocationContext import org.infinispan.interceptors.base.BaseCustomInterceptor class PutKeyValueTraceInterceptor extends BaseCustomInterceptor { override def visitPutKeyValueCommand(...
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 elegans import Cells._ import Constraints._ import Experiments._ import Invariants._ import scala.collection.mutable.{Map => MutableMap, Set => MutableSet} import scala.util.Random object TraceSummarization { private def portValues2int(vs: Seq[Boolean]): Int = { val idx = vs.lastIndexOf(true) idx +...
Explain and rewrite the following Scala code:
package au.csiro.ict import org.scalatra.ScalatraServlet import au.csiro.ict.JsonGenerator._ import au.csiro.ict.Cache._ import au.csiro.ict.Validators._ import com.mongodb.casbah.Imports._ import com.mongodb.casbah.commons import com.mongodb //import com.mongodb.casbah.query.Imports._ /** * Metadata key is limited...
Explain and rewrite the following Scala code:
package org.broadinstitute.clio.client.dispatch import java.net.URI import akka.NotUsed import akka.stream.scaladsl.Source import cats.syntax.show._ import io.circe.Json import org.broadinstitute.clio.client.commands.DeleteCommand import org.broadinstitute.clio.client.util.IoUtil import org.broadinstitute.clio.client...
Explain and rewrite the following Scala code:
// Generated by the Scala Plugin for the Protocol Buffer Compiler. // Do not edit! // // Protofile syntax: PROTO3 package com.google.protobuf.field_mask /** `FieldMask` represents a set of symbolic field paths, for example: * * paths: "f.a" * paths: "f.b.d" * * Here `f` represents a field in some ro...
Explain and rewrite the following Scala code:
package scala.runtime import java.io.Serializable class BooleanRef(var elem: Boolean) extends Serializable { override def toString() = String.valueOf(elem) } object BooleanRef { def create(elem: Boolean): BooleanRef = new BooleanRef(elem) def zero(): BooleanRef = new BooleanRef(false) } class VolatileBooleanRe...
Explain and rewrite the following Scala code:
import stainless.lang._ object ArrayParamMutation6 { def multipleEffects(a1: Array[BigInt], a2: Array[BigInt]): Unit = { require(a1.length > 0 && a2.length > 0) a1(0) = 11 a2(0) = 12 } ensuring(_ => a1(0) != a2(0)) def f(a1: Array[BigInt], a2: Array[BigInt]): Unit = { require(a1.length > 0 && a...
Explain and rewrite the following Scala code:
/////////////////////////////////////////////////////////////////////////////// // ConvertCophir.scala // // Copyright (C) 2012-2014 Ben Wing, The University of Texas at Austin // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. /...
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 package xml pack...
Explain and rewrite the following Scala code:
package com.nummulus.amqp.driver.blackbox import com.nummulus.amqp.driver.AmqpDriverFactory import akka.actor.ActorSystem private[blackbox] class BlackBoxAmqpDriverFactory(system: ActorSystem) extends AmqpDriverFactory { private val driver = new BlackBoxAmqpDriver(system) /** * Returns the singleton black b...
Explain and rewrite the following Scala code:
/* * Copyright 2020 Precog Data * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to ...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com> */ package play.api.mvc import java.time.{ Instant, ZoneId } import org.specs2.mutable._ import play.api.http.{ JWTConfiguration, SecretConfiguration } import play.api.mvc.Cookie.SameSite import play.core.cookie.encoding.{ DefaultCookie, Serve...
Explain and rewrite the following Scala code:
package me.fornever.githublo.ui import scalafxml.core.ControllerDependencyResolver import scala.reflect.runtime.universe.Type class ComplexDependencyResolver(resolvers: ControllerDependencyResolver*) extends ControllerDependencyResolver { override def get(paramName: String, dependencyType: Type): _root_.scala.Opti...
Explain and rewrite the following Scala code:
package atto package parser import cats.{ Eval, Foldable } import cats.data.NonEmptyList import cats.implicits._ import java.lang.{ String, SuppressWarnings } import scala.{ Array, Nil, Int, Unit, List, Boolean, Either, Left, Right, StringContext, PartialFunction, Option, Some } import scala.Predef.augmentString imp...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014-2018 by The Monix Project Developers. * See the project homepage at: https://monix.io * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache...
Explain and rewrite the following Scala code:
package com.cave.metrics.data.postgresql import com.cave.metrics.data.{Token, Organization} object OrganizationSerializer { def fromPostgresRecord(list: List[(Tables.TokensRow, Tables.OrganizationsRow)]) = { if (list.nonEmpty) { val tokens: List[Token] = TokenSerializer.fromPostgresRecord(list.map(_._1).t...
Explain and rewrite the following Scala code:
/*********************************************************************** * Copyright (c) 2013-2020 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 com.eevolution.context.dictionary.infrastructure.service.impl import java.util.UUID import com.eevolution.context.dictionary.infrastructure.repository.TenantInfoRepository import com.eevolution.context.dictionary.infrastructure.service.TenantInfoService import com.lightbend.lagom.scaladsl.api.ServiceCall impo...
Explain and rewrite the following Scala code:
/* * Copyright 2014 Databricks * * 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:
/* * BetaReduction.scala * */ package at.logic.gapt.expr /* The BetaReduction object encapsulates two functions: * 1) betaNormalize, which transforms a lambda expression to beta normal form. * 2) betaReduce, which applies only one rewrite step to a lambda expression. * * These functions take additio...
Explain and rewrite the following Scala code:
/* * Copyright 2015 Roberto Tyley * * 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 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:
package org.scalaide.refactoring.internal.ui import org.eclipse.swt.events.ModifyEvent import org.eclipse.swt.events.ModifyListener import org.eclipse.swt.layout.GridData import org.eclipse.swt.layout.GridLayout import org.eclipse.swt.widgets.Composite import org.eclipse.swt.widgets.Label import org.eclipse.swt.widget...
Explain and rewrite the following Scala code:
/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ package viper.silicon.interfaces import viper.silver.ast import viper.silver.verifier.PartialVerificationErro...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
import com.twitter.scalding._ import com.twitter.scalding.mathematics.Matrix /* * MatrixTutorial3.scala * * Loads two directed graph adjacency matrices where a[i,j] = 1 if there is an edge from a[i] to b[j] * and computes the intersection and the differences between the two * yarn jar target/scalding-tutorial-0.14...
Explain and rewrite the following Scala code:
package com.kpbochenek.cats import cats.data.{Coproduct, State} import cats.free.{Free, Inject} import cats.{Id, ~>} import com.kpbochenek.cats.FenwickPureInterpreter.FenwickTreeState import com.kpbochenek.cats.FenwickTreeModel.FenwickTreeModel import com.kpbochenek.cats.FenwickWrapper.{FUtils, FenwickUtils} import s...
Explain and rewrite the following Scala code:
package org.eknet.sitebag import akka.actor._ import scala.util.control.NonFatal import akka.io import spray.can.Http import java.net.InetSocketAddress import scala.collection.immutable import akka.io.Inet import spray.can.server.ServerSettings import spray.io.ServerSSLEngineProvider import org.eknet.sitebag.MainActor...
Explain and rewrite the following Scala code:
package org.scalatest.tools import org.scalatools.testing._ import org.scalatest.tools.Runner.parsePropertiesArgsIntoMap import org.scalatest.tools.Runner.parseCompoundArgIntoSet /** * Class that makes ScalaTest tests visible to sbt. * * @author Josh Cough * @author Bill Venners */ class ScalaTestFra...
Explain and rewrite the following Scala code:
/* * Copyright 2001-2013 Artima, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agre...
Explain and rewrite the following Scala code:
package pl.newicom.dddd.test.dummy import akka.actor.{ActorPath, Props} import pl.newicom.dddd.actor.PassivationConfig import pl.newicom.dddd.aggregate._ import pl.newicom.dddd.messaging.correlation.EntityIdResolution import pl.newicom.dddd.office.{LocalOfficeId, SagaConfig} import pl.newicom.dddd.process._ import pl....
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 2014-2022 Netflix, 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 TAPL2.FullIsoRec import TAPL2.FullEquiRec.FullEquiRec import TAPL2.Lib._ case class TyVar(i: String) extends Ty case class TyRecord(els: List[(String, Ty)]) extends Ty case class TyArr(t1: Ty, t2: Ty) extends Ty case object TyNat extends Ty case class TyVariant(els: List[(String, Ty)]) extends Ty case o...
Explain and rewrite the following Scala code:
object MultiProject extends sbt.Build { import sbt._ import sbt.Keys._ import ls.Plugin._ def scriptedExtras: Seq[Setting[_]] = Seq( InputKey[Unit]("contents") <<= inputTask { (argsTask: TaskKey[Seq[String]]) => (argsTask, streams) map { (args, out) => args match { ...
Explain and rewrite the following Scala code:
import org.scalatest.FunSuite package object pkg1 { @doubler def foo(x: Int) = x @doubler val bar = 2 @doubler var baz = 3 @doubler lazy val bax = 4 @doubler type T = Int } package pkg2 { @hello object `package` } class PackageObject extends FunSuite { test("package object members") ...
Explain and rewrite the following Scala code:
package com.twitter.scalding.spark_backend import com.twitter.scalding.{Config, Mode, WritableSequenceFile, TextLine} import com.twitter.scalding.typed.{ Resolver, TypedSource, TypedSink } import org.apache.spark.rdd.RDD import org.apache.spark.storage.StorageLevel import org.apache.spark.sql.SparkSession import scala...
Explain and rewrite the following Scala code:
/* * Copyright 2014 Treode, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to...
Explain and rewrite the following Scala code:
/* * Copyright (C) Lightbend Inc. <https://www.lightbend.com> */ package play.core.server.common import java.net.InetAddress import com.google.common.net.InetAddresses import org.specs2.mutable.Specification import play.api.mvc.Headers import org.specs2.mutable.Specification import play.api.mvc.Headers import play...
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:
/* * Copyright 2018 Analytics Zoo Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or...
Explain and rewrite the following Scala code:
package controllers import play.api._ import play.api.mvc._ import play.api.libs.concurrent.Execution.Implicits._ import scala.concurrent.Future import knock.{HttpKnock, Urls} object Application extends Controller with Urls { def index = Action.async { val urls = getUrls val knock = new HttpKnock ...
Explain and rewrite the following Scala code:
package howitworks.macwiree class TupleToArgs extends wp.Spec { def f(i: Int, s: String, d: Double): String = s"$i $s $d" "how to apply a function to a tuple" in { val tuple = (10, "abc", 11.02) (f _).tupled(tuple) } }
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 dpla.ingestion3.harvesters.file import java.io.{File, FileInputStream} import java.util.zip.GZIPInputStream import dpla.ingestion3.confs.i3Conf import org.apache.commons.io.IOUtils import org.apache.log4j.Logger import org.apache.spark.sql.{DataFrame, SparkSession} import com.databricks.spark.avro._ import dp...
Explain and rewrite the following Scala code:
package samples import akka.actor.{ActorSystem, Props} import chapter3.GreetingLogActor import org.junit._ import Assert._ @Test class JunitTest { @Test def testOK() = assertTrue(true) @Test def testKO() = { val pro1=Props[GreetingLogActor] val system=ActorSystem("mySystem") val ...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014-2018 by The Monix Project Developers. * See the project homepage at: https://monix.io * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache...
Explain and rewrite the following Scala code:
/* * 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.ddf.flink.etl import java.security.SecureRandom import java.text.SimpleDateFormat import java.util import io.ddf.flink.FlinkConstants import io.ddf.{DDFManager, DDF} import io.ddf.content.Schema import io.ddf.content.Schema.{Column, ColumnType} import io.ddf.etl.IHandleMissingData import io.ddf.etl.IHandle...
Explain and rewrite the following Scala code:
package rpgboss.player import rpgboss._ import rpgboss.model._ import rpgboss.model.event._ import rpgboss.model.resource._ class EventSpec extends UnitSpec { "Events" should "activate and run their script" in { val testIntValue = 42 // arbitrary val test = new MapScreenTest { override def setupMapDa...
Explain and rewrite the following Scala code:
package com.eclipsesource.schema import com.eclipsesource.schema.drafts.Version4 import com.eclipsesource.schema.internal.Keywords import com.eclipsesource.schema.internal.serialization.SchemaReads import org.specs2.mutable.Specification import play.api.libs.json._ class ErrorReportingSpec extends Specification { ...
Explain and rewrite the following Scala code:
/* * Copyright 2016 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
/* Copyright 2013 Twitter, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
Explain and rewrite the following Scala code:
/* sbt -- Simple Build Tool * Copyright 2011 Mark Harrah * Copyright 2012 Johannes Rudolph * * This was basically copied from the sbt source code and then adapted to use * `sbtVersion in pluginCrossBuild`. */ package sbt import complete.DefaultParsers._ import complete.Parser import sbt.Keys._ import Project._ i...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
/** * Copyright (C) 2007 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 prog...
Explain and rewrite the following Scala code:
package com.gigaspaces.sbp import java.util.Date import org.slf4j.{Logger, LoggerFactory} import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent._ import scala.concurrent.duration._ import scala.language.postfixOps /** * Created by IntelliJ IDEA. * User: jason * Date: 8/7/14 * Time: 1...
Explain and rewrite the following Scala code:
package xyz.hyperreal.markup import util.parsing.input.{Reader, Position} abstract class Token { private [markup] var _pos: Position = null private [markup] var _rest: Reader[Char] = null def pos = _pos def pos( p: Position ) = { _pos = p this } def rest = _rest def rest( r: Reader[Char] ) = { ...
Explain and rewrite the following Scala code:
package fpinscala.monoids import org.junit.runner.RunWith import org.scalacheck.Arbitrary import org.scalacheck.Arbitrary.arbitrary import org.scalacheck.Gen import org.scalatest.FlatSpec import org.scalatest.prop.PropertyChecks import fpinscala.testing.{Gen => FPGen} import java.util.concurrent.Executors @RunWith(cl...
Explain and rewrite the following Scala code:
package com.atanana.posters import cats.data.EitherT import scala.concurrent.Future trait Poster { def postAsync(message: String): EitherT[Future, Throwable, Unit] }
Explain and rewrite the following Scala code:
package com.vmware import scala.sys.process._ object VmDir { private val base = "/usr/lib/vmware-vmdir/bin/" private val vdcpromo = base + "vdcpromo" def CreateTenant(user: String, password: String, tenant: String) = { val cmd = "%s -u %s -w %s -d %s -t".format(vdcpromo, user, password, tenant) val ret = cmd....
Explain and rewrite the following Scala code:
// Expressions.scala val c = { val i1 = 2 val j1 = 4/i1 i1 * j1 } println(c) /* Output: 4 */
Explain and rewrite the following Scala code:
package reactivemongo.api.commands.bson import reactivemongo.api.ReadConcern import reactivemongo.api.commands.{ CommandError, UnitBox } import reactivemongo.bson.{ BSONBooleanLike, BSONDocument, BSONDocumentReader, BSONDocumentWriter } object CommonImplicits { implicit object UnitBoxReader extends De...
Explain and rewrite the following Scala code:
/******************************************************************************* Copyright (c) 2012-2013, KAIST, S-Core. All rights reserved. Use is subject to license terms. This distribution may include materials developed by third parties. **********************************************************...
Explain and rewrite the following Scala code:
/* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/...
Explain and rewrite the following Scala code:
package be.wegenenverkeer.atomium.client import java.util.concurrent.TimeUnit import javax.xml.bind.annotation._ import be.wegenenverkeer.atomium.japi import be.wegenenverkeer.atomium.japi.client.FeedEntry import be.wegenenverkeer.atomium.japi.format.Entry import com.github.tomakehurst.wiremock.WireMockServer import...
Explain and rewrite the following Scala code:
package nomad.strat.service.persistence.entities import slick.driver.H2Driver.api._ import slick.lifted.Tag abstract class BaseTable[T](tag: Tag, name: String) extends Table[T](tag, name) { def id = column[Long]("id", O.PrimaryKey, O.AutoInc) }
Explain and rewrite the following Scala code:
package demo package components package reacttable import chandu0101.macros.tojs.GhPagesMacros import chandu0101.scalajs.react.components.{JsonUtil, ReactTable} import demo.util.SampleData import japgolly.scalajs.react._ import japgolly.scalajs.react.vdom.prefix_<^._ object ReactTableCustomCell { val code = GhPage...
Explain and rewrite the following Scala code:
package shopping.products trait Product { val id: Int val cost: Double }
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.jatescher import com.typesafe.sbt.SbtNativePackager._ import com.typesafe.sbt.packager.archetypes.scripts.BashStartScriptPlugin import com.typesafe.sbt.packager.archetypes.scripts.BashStartScriptPlugin.autoImport._ import com.typesafe.sbt.packager.archetypes.scripts.BatStartScriptPlugin import com.typesafe...
Explain and rewrite the following Scala code:
package io.buoyant.k8s.istio import com.twitter.finagle.Path import com.twitter.util.Future import io.buoyant.k8s.istio.ClusterCache.Cluster import istio.proxy.v1.config.StringMatch.OneofMatchType import istio.proxy.v1.config._ trait IstioIdentifierBase[Req] { /** * Defines a request's metadata for istio rules ...
Explain and rewrite the following Scala code:
package timezra.dropbox.core import java.text.DateFormat import java.text.SimpleDateFormat import java.util.Locale import org.junit.runner.RunWith import org.scalatest.Inside import ContentTypes.`text/javascript` import spray.http.ContentTypes.`application/json` import spray.http.HttpData.Bytes import spray.http.HttpE...
Explain and rewrite the following Scala code:
/* __ *\\ ** ________ ___ / / ___ __ ____ Scala.js API ** ** / __/ __// _ | / / / _ | __ / // __/ (c) 2013, LAMP/EPFL ** ** __\\ \\/ /__/ __ |/ /__/ __ |/_// /_\\ \\ http://scala-lang.org/ ** ** /____/\\...
Explain and rewrite the following Scala code:
package org.example import scalaz._, Scalaz._ package object validation { type NELError[A] = ValidationNel[Error, A] val V = Applicative[NELError] trait Valid def validate[A, B](field: ErrorField)(a: A)(implicit parent: Maybe[ErrorField], v: A => \\/[(ErrorCode, String), B]) : ValidationNel[Error, B] = {...
Explain and rewrite the following Scala code:
package net.mauhiz.repocleaner import java.io.IOException import java.nio.charset.StandardCharsets import java.nio.file.{DirectoryStream, Files, Path, Paths} import java.security.MessageDigest import java.util.concurrent.TimeUnit import org.apache.commons.codec.binary.Hex import org.apache.commons.io.FileUtils import...
Explain and rewrite the following Scala code:
package com.socrata.pg.store.index import com.socrata.datacoordinator.common.soql.sqlreps._ import com.socrata.datacoordinator.truth.metadata.ColumnInfo import com.socrata.datacoordinator.truth.sql.SqlColumnCommonRep import com.socrata.pg.soql.SqlColIdx import com.socrata.soql.types._ import com.vividsolutions.jts.geo...
Explain and rewrite the following Scala code:
package at.logic.gapt.proofs.expansion import at.logic.gapt.expr._ import at.logic.gapt.utils.generatedUpperSetInPO object eliminateCutsET { def apply( expansionProof: ExpansionProofWithCut ): ExpansionProof = { if ( expansionProof.cuts.isEmpty ) return expansionProof.toExpansionProof def simplifiedEPWC( cu...
Explain and rewrite the following Scala code:
/* Copyright 2008-2012 E-Hentai.org http://forums.e-hentai.org/ ehentai@gmail.com This file is part of Hentai@Home. Hentai@Home 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, o...
Explain and rewrite the following Scala code:
package gitbucket.core.service import gitbucket.core.util.JGitUtil.CommitInfo import gitbucket.core.util.StringUtil._ import gitbucket.core.util.Implicits._ import gitbucket.core.util.SyntaxSugars._ import gitbucket.core.controller.Context import gitbucket.core.model.{ Account, CommitState, Issue, IssueComment...
Explain and rewrite the following Scala code:
/** * This file is part of mycollab-esb. * * mycollab-esb 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. * * mycollab-esb is d...
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:
package specs import org.junit.runner.RunWith import org.specs2.mutable.Specification import org.specs2.runner.JUnitRunner import com.fasterxml.jackson.databind.ObjectMapper import com.typesafe.config.ConfigFactory import scala.collection.JavaConversions._ import scala.collection.JavaConverters._ import play.api.test....
Explain and rewrite the following Scala code:
val a = 1 val b = 2 if (a > b) { println("true") } else { println("false") }
Explain and rewrite the following Scala code:
package ca.pgx.common.db.entities import ca.pgx.common.db.collections.CollectionNames import ca.pgx.common.db.helpers.InjectableMetaRecord import com.foursquare.index.IndexedRecord import net.liftweb.mongodb.record.MongoRecord import net.liftweb.mongodb.record.field.ObjectIdPk import net.liftweb.record.field.StringFie...
Explain and rewrite the following Scala code:
package com.bfm.topnotch.tnview import com.bfm.topnotch.SparkApplicationTester import com.bfm.topnotch.TnTestHelper import org.scalatest.{Matchers, Tag} /** * The tests for [[com.bfm.topnotch.tnview.TnViewCreator TnViewCreator]]. */ class TnViewCreatorTest extends SparkApplicationTester with Matchers { ...
Explain and rewrite the following Scala code:
package com.twitter.finagle.mysql.protocol import org.jboss.netty.buffer.{ChannelBuffer, ChannelBuffers} /** * Represents a logical packet received from MySQL. * A MySQL packet consists of a header and body. */ case class Packet(header: PacketHeader, body: Array[Byte]) case class PacketHeader(size: Int, seq: Shor...
Explain and rewrite the following Scala code:
package underscore.annihilator import cats.Order sealed trait Interval[A] extends AnnihilatorSyntax { import cats.syntax.order._ import Interval._ def intersect(that: Interval[A])(implicit order: Order[A]): Interval[A] = (this and that){ (i1, i2) => if((i2.end compare i1.start) < 0 || (i1.end compare...
Explain and rewrite the following Scala code:
package org.sisioh.aws4s.sns.model import com.amazonaws.services.sns.model.SetSubscriptionAttributesRequest import org.sisioh.aws4s.PimpedType object SetSubscriptionAttributesRequestFactory { def create(): SetSubscriptionAttributesRequest = new SetSubscriptionAttributesRequest() def create(subscriptionArn: ...
Explain and rewrite the following Scala code:
package mypipe.mysql import mypipe.api.Conf import mypipe.api.consumer.{ BinaryLogConsumerErrorHandler, BinaryLogConsumerListener } import mypipe.api.data.Table import mypipe.api.event._ import org.slf4j.LoggerFactory trait ConfigBasedErrorHandlingBehaviour[BinaryLogEvent, BinaryLogPosition] extends BinaryLogConsumer...
Explain and rewrite the following Scala code:
package pl.touk.nussknacker.engine.requestresponse.deployment import io.circe.generic.JsonCodec import pl.touk.nussknacker.engine.api.ProcessVersion import pl.touk.nussknacker.engine.canonicalgraph.CanonicalProcess import pl.touk.nussknacker.engine.deployment.DeploymentData //TODO: now we pass process version to runt...
Explain and rewrite the following Scala code:
package io.prediction.examples.pfriendrecommendation import io.prediction.controller.EmptyParams import io.prediction.controller.PPreparator import io.prediction.controller.EmptyPreparatorParams import org.apache.spark.SparkContext import org.apache.spark.SparkContext._ import org.apache.spark.rdd.RDD import scala.i...
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.async ...
Explain and rewrite the following Scala code:
package com.rklaehn.interval import ichi.bench._ import spire.syntax.all._ object IntervalSeqBench extends App { def makeOnOffProfile(n: Int, offset: Int = 0, stride: Int = 2) = { val support = (0 until n).map(_ * stride + offset).toArray IntervalSeqArbitrary.makeProfileXor(false, support, Array.fill(suppo...
Explain and rewrite the following Scala code:
package org.alitouka.spark.dbscan.spatial import org.alitouka.spark.dbscan._ /** Represents a point in multi-dimensional space and metadata required by the distributed DBSCAN algorithm * * @param coordinates Point's coordinates * @param pointId A unique identifier of the point * @param boxId An identifier of ...
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 io.really.coffeescript import javax.script._ import jdk.nashorn.api.scripting._ import javax.script.ScriptContext._; import scala.io.Source /** * CoffeeScriptCompiler relies on Java8's Nashorn implementation for faster performance and more predictable output */ class CoffeeScriptCompiler(bare: Boolean = tr...
Explain and rewrite the following Scala code:
package com.twitter.finagle.stats import java.io.PrintStream import scala.collection.mutable /** In-memory stats receiver for testing. */ class InMemoryStatsReceiver extends StatsReceiver { val repr = this val counters = new mutable.HashMap[Seq[String], Int] with mutable.SynchronizedMap[Seq[St...