instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
import java.io._ import scala.tools.nsc._ import scala.util.Random /** * The BenchGenerator will generate and compile Scala and C code to a class file and a native library, respecctively. */ object BenchGenerator { // TODO: Make this all a bit less static val benchSourceDir: String = "bench" val outClassDi...
Explain and rewrite the following Scala code:
package io.truthencode.ddo.api.model.effect trait ValueInfo { def intValue: Option[Int] def hasValue: Boolean = intValue.isDefined }
Explain and rewrite the following Scala code:
package com.twitter.finagle.example.memcache import com.twitter.app.Flag import com.twitter.app.App import com.twitter.conversions.time._ import com.twitter.finagle.builder.{Cluster, ClientBuilder} import com.twitter.finagle.memcached import com.twitter.finagle.memcached.{CacheNode, CachePoolCluster} import com.twitte...
Explain and rewrite the following Scala code:
/* * Export.scala * (SysSon) * * Copyright (c) 2013-2017 Institute of Electronic Music and Acoustics, Graz. * Copyright (c) 2014-2019 Hanns Holger Rutz. All rights reserved. * * This software is published under the GNU General Public License v3+ * * * For further information, please contact Hanns Holger R...
Explain and rewrite the following Scala code:
package org.scalaide.ui.internal.editor.outline import scala.tools.nsc.Settings import scala.tools.nsc.interactive.CompilerControl import scala.tools.nsc.interactive.Global import scala.tools.nsc.reporters.ConsoleReporter import scala.reflect.internal.util.BatchSourceFile import scala.reflect.internal.util.SourceFile ...
Explain and rewrite the following Scala code:
// Solution-4.scala // Solution to Exercise 4 in "Values" val s = "ABC1234" println(s) // This won't work: s = "DEF1234" println("You can't change a val") /* OUTPUT_SHOULD_CONTAIN error: reassignment to val s = "DEF1234" ^ one error found */
Explain and rewrite the following Scala code:
package com.pwootage.metroidprime.dump import java.io._ import java.nio.file.{Files, Path, Paths, StandardOpenOption} import java.util.zip.{Deflater, DeflaterOutputStream, InflaterOutputStream} import com.pwootage.metroidprime.formats.common.PrimeVersion import com.pwootage.metroidprime.formats.io.PrimeDataFile impor...
Explain and rewrite the following Scala code:
/* * (c) Copyright 2016 Hewlett Packard Enterprise Development LP * * 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 b...
Explain and rewrite the following Scala code:
package spark.deploy.worker import akka.actor.{ActorRef, ActorSystem} import akka.dispatch.Await import akka.pattern.ask import akka.util.{Duration, Timeout} import akka.util.duration._ import cc.spray.Directives import cc.spray.typeconversion.TwirlSupport._ import cc.spray.http.MediaTypes import cc.spray.typeconversi...
Explain and rewrite the following Scala code:
/* * This file is part of the "silex" library of helpers for Apache Spark. * * Copyright (c) 2015 Red Hat, 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....
Explain and rewrite the following Scala code:
package org.higherstate.jameson.failures import org.higherstate.jameson.Path case class InvalidValueFailure(source:Any, _message:String, unexpected:Any, path:Path) extends PathFailure { def message:String = s"${_message}\\n\\rValue: $unexpected\\n\\rPath: $path" }
Explain and rewrite the following Scala code:
package ch.ninecode.cim import java.io.File import org.apache.spark.sql.SparkSession class CIMIntegrityCheckSuite extends ch.ninecode.SparkSuite { val FILE_DEPOT = "data/" override def run (testName: Option[String], args: org.scalatest.Args): org.scalatest.Status = { // unpack the zip files ...
Explain and rewrite the following Scala code:
import Math.sqrt object Main { def main(args: Array[String]) { println(primeFactors(13195:Long)) // java.lang.StackOverflowError... :sweat: // println(primeFactors(600851475143:Long)) } def primeFactors(n: Long): List[Long] = { val primeFactorCandidates = primes(2, sqrt(n.asInstanceOf[Float]).as...
Explain and rewrite the following Scala code:
package org.xmly.thrall.rec.protocol class RecRequest { var uid: Int = _ var qid: Int = _ def getUid = uid def getQid = qid def setUid(uid: Int) = this.uid = uid def setQid(qid: Int) = this.qid = qid }
Explain and rewrite the following Scala code:
package com.truecar.mleap.runtime.transformer import com.truecar.mleap.core.feature.HashingTermFrequency import com.truecar.mleap.runtime.attribute.{CategoricalAttribute, AttributeGroup, AttributeSchema} import com.truecar.mleap.runtime.transformer.builder.TransformBuilder import com.truecar.mleap.runtime.transformer....
Explain and rewrite the following Scala code:
package com.github.fellowship_of_the_bus package lib package slick2d package ui import org.newdawn.slick.{GameContainer, Graphics, Color, Input} import org.newdawn.slick.util.InputAdapter import org.newdawn.slick.gui.MouseOverArea import org.newdawn.slick.state.{StateBasedGame} import lib.slick2d.game.SlickGameConfig...
Explain and rewrite the following Scala code:
package de.ioswarm.cassie import java.net.InetAddress import java.nio.ByteBuffer import java.sql.{Time, Timestamp, Date => SQLDate} import java.text.SimpleDateFormat import java.time.{Instant, ZoneId} import java.util.{Date, UUID} import com.datastax.driver.core.LocalDate /** * Created by andreas on 24.08.17. */...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.lang.psi.stubs import com.intellij.psi.stubs.StubElement import org.jetbrains.plugins.scala.lang.psi.api.statements.params.ScParameterClause /** * User: Alexander Podkhalyuzin * Date: 19.10.2008 */ trait ScParamClauseStub extends StubElement[ScParameterClause] { def isImpli...
Explain and rewrite the following Scala code:
package main.java.piratebot.pirates import main.java.piratebot._ class SpanishSpy(game: Game, player: Player) extends Pirate(game, player) { val rank = 17 val name = "SpanishSpy" override def dayAction(round : Round): RetriableMethodResponse.Value = { for (_ <- 1 to player.booty(Booty.SpanishOffi...
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 de.frosner.broccoli.controllers import java.util.concurrent.TimeUnit import cats.data.OptionT import cats.instances.future._ import com.mohiva.play.silhouette.api.LoginInfo import com.mohiva.play.silhouette.api.util.Credentials import de.frosner.broccoli.auth.{Account, Role} import de.frosner.broccoli.service...
Explain and rewrite the following Scala code:
package org.scalatra.ssgi package servlet import org.scalatest.{OneInstancePerTest, Spec} import org.scalatest.matchers.ShouldMatchers import org.scalatest.mock.MockitoSugar import org.mockito.Mockito._ import javax.servlet.http.HttpServletRequest import scala.collection.JavaConversions._ import java.util.{Enumeration...
Explain and rewrite the following Scala code:
package com.avsystem.commons package annotation /** * When applied on varargs parameter, indicates that at least some number of parameters is required. * This is later checked by the static analyzer. * <br/> * WARNING: implementation of method which takes a varargs parameter may NOT assume that given number of...
Explain and rewrite the following Scala code:
package com.example.app import java.io.FileOutputStream import java.net.URI import akka.actor.ActorSystem import akka.http.scaladsl.Http import akka.http.scaladsl.model.{HttpRequest, StatusCodes} import akka.stream.Materializer import akka.stream.scaladsl.{Flow, Sink} import com.example.entity.MediaTweet i...
Explain and rewrite the following Scala code:
package org.scalatra package object servlet { @deprecated("Use skinny.engine.SkinnyEngineListener instead", since = "2.0.0") type ScalatraListener = skinny.engine.SkinnyEngineListener @deprecated("Use skinny.engine.SkinnyEngineBase instead", since = "2.0.0") type ServletBase = skinny.engine.SkinnyEngineBase ...
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 sbt.Keys._ import sbt._ import sbtstudent.AdditionalSettings import sbtstudent.StudentCommandsPlugin._ object CommonSettings { lazy val commonSettings = Seq( Compile / scalacOptions ++= CompileOptions.compileOptions, Compile / unmanagedSourceDirectories := List((Compile / scalaSource).value, (Compile ...
Explain and rewrite the following Scala code:
package one.lockstep.util import scodec._ import scala.language.implicitConversions package object protocol { implicit def prefaceToMatcher(preface: Preface): PrefaceMatcher = PrefaceMatcher.fromPreface(preface) implicit def versionToMatcher(version: Version): PrefaceMatcher = PrefaceMatcher.fromVersion(versio...
Explain and rewrite the following Scala code:
import scala.reflect.runtime.universe._ import scala.reflect.macros.blackbox.Context object Impls1 { def foo[U: c.WeakTypeTag: Numeric](c: Context) = { import c.universe._; q"42" } } object Impls2 { def foo = ??? } object Impls3 { def foo(c: scala.reflect.api.Universe) = ??? } object Impls4 { def foo(cs: Co...
Explain and rewrite the following Scala code:
package delta.process import scala.concurrent.Future import scala.util.control.NonFatal /** * @tparam ID Stream identifier * @tparam EVT Top event type * @tparam S state type */ trait TransactionProcessor[SID, EVT, S >: Null] { def name: String protected type Transaction = delta.Transaction[SID, _ >: EVT] ...
Explain and rewrite the following Scala code:
package com.dominikgruber.fpinscala.chapter05 import org.scalatest._ class Exercise03Spec extends FlatSpec with Matchers { "takeWhile" should "take a few elements" in { Stream(1, 2, 3, 4, 5).takeWhile(_ < 3).toList should be (List(1, 2)) } it should "not take anything" in { Stream(1, 2, 3).takeWhile(_...
Explain and rewrite the following Scala code:
package com.divisiblebyzero.ada.player import com.divisiblebyzero.ada.view.component.Board import com.divisiblebyzero.chess.Move import com.divisiblebyzero.chess.ai.Search class ComputerPlayer extends Player { class SearchThread extends Thread { def this(board: Board, color: Int) { this () this.boa...
Explain and rewrite the following Scala code:
/** * Created on February 26, 2011 * Copyright (c) 2011, Wei-ju Wu * 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 * ...
Explain and rewrite the following Scala code:
package chee.properties import MapGet._ object Patterns { type Pattern = MapGet[Either[String, String]] type PatternPred = MapGet[Either[String, Boolean]] implicit class MapGetEitherOps[A,B](p: MapGet[Either[A,B]]) { def rmap[C](f: B => C): MapGet[Either[A, C]] = p.map(_.right.map(f)) def rmap2...
Explain and rewrite the following Scala code:
package org.chipmunk.entity.relation.m2o import org.chipmunk.TestSchema.Animal import org.chipmunk.entity.Identifiable import org.chipmunk.test.relation.Query import org.mockito.Mockito.verify import org.scalatest.fixture import org.scalatest.mock.MockitoSugar import org.squeryl.dsl.{ ManyToOne => SM2O } class ManyTo...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
/* * Licensed to The Apereo Foundation under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional * information regarding copyright ownership. * * The Apereo Foundation licenses this file to you under the Apache License, * Version 2.0, (the "License"); you ma...
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 t5853 final class C(val x: Int) extends AnyVal { def ppp[@specialized(Int) T](y: T) = () } class Foo { def f = new C(1) ppp 2 } /* Original SI-5853 test-case. */ object Bippy { implicit final class C(val x: Int) extends AnyVal { def +++[@specialized T](y: T) = () } def f = 1 +++ 2 } ...
Explain and rewrite the following Scala code:
import sbt._ object Dependencies { val akkaVersion = "2.5.23" lazy val clist = Seq( "org.backuity.clist" %% "clist-core" % "3.5.0", "org.backuity.clist" %% "clist-macros" %...
Explain and rewrite the following Scala code:
// Copyright (C) 2015 Sebastian Bøe, Joakim Andersson // License: BSD 2-Clause (see LICENSE for details) package TurboRav import Chisel._ import Constants._ // This class implements the transmitter seen in figure 3-2 of the DVI // V1.0 spec. class dvi_tmds_transmitter extends Module { val num_chan = 3 val pixel_...
Explain and rewrite the following Scala code:
/* Copyright 2015 UniCredit S.p.A. * * 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...
Explain and rewrite the following Scala code:
package ohnosequences.mg7.loquats import ohnosequences.mg7._, csv._ import ohnosequences.ncbitaxonomy._, titan._ import ohnosequences.loquat._, utils.files._ import ohnosequences.statika._ import ohnosequences.cosas._, types._, klists._ import ohnosequences.datasets._ import java.io.File import com.bio4j.titan.model.n...
Explain and rewrite the following Scala code:
/* * Copyright 2015 * * 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, ...
Explain and rewrite the following Scala code:
package instagram.api.yaml import de.zalando.play.controllers._ import org.scalacheck._ import org.scalacheck.Arbitrary._ import org.scalacheck.Prop._ import org.scalacheck.Test._ import org.specs2.mutable._ import play.api.test.Helpers._ import play.api.test._ import play.api.mvc.MultipartFormData.FilePart import pla...
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) 2012 Inria, University Lille 1. * * This file is part of PowerAPI. * * PowerAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your...
Explain and rewrite the following Scala code:
package com.github.jefersonm.sandbox.dojo class TennisMatch { var scoreA = 0 var scoreB = 0; var game = 0 var sets = 0 def getSets() = sets def getGame() = game def getScore(scoreA:Int, scoreB:Int) = (scoreA, scoreB) match { case (0 , 0) => "0 X 0" case (40 ,40) => "DEUCE" case _ => "" ...
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 io.transwarp.midas.constant.midas.params.classification /** * Created by liusheng on 4/26/16. */ object SVMParams { val weight = "weight" val intercept = "intercept" val stepSize = "stepSize" val numIterations = "numIterations" val regParam = "regParam" val miniBatchFraction = "miniBatchFraction...
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:
package me.jairam.csv import java.io.{File, FileReader, IOException} import java.math.BigDecimal import com.opencsv import com.opencsv.CSVParser import me.jairam.schema.{ BOOLEAN, DECIMAL, DOUBLE, DataSchema, DataType, INT, LONG, NULL, STRING } import org.apache.tika.Tika import collection.JavaConv...
Explain and rewrite the following Scala code:
package jigg.nlp.ccg /* Copyright 2013-2016 Hiroshi Noji 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 test import org.specs2.mutable._ import play.api.mvc.{Action, Results} import play.api.test._ import play.api.test.Helpers._ import scaldi.play.{FakeRouterModule, ScaldiApplicationBuilder} class IntegrationSpec extends Specification { "Application" should { "work from within a browser" in { ...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
package vorquel.mod.vderps.helper import net.minecraft.creativetab.CreativeTabs import vorquel.mod.vderps.item.ItemBootsBucket object Ref { // Constants val MOD_ID = "VDerps" val MOD_NAME = "Vorquel's Derps" val VERSION = "1.7.10-0.0.0" val CLIENT_PROXY_CLASS = "vorquel.mod.vderps.proxy.ClientProxy" val ...
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:
/* * Copyright (C) 2016-2017 Lightbend Inc. <https://www.lightbend.com> */ package com.lightbend.lagom.internal.persistence.cassandra import akka.Done import akka.actor.{ ActorSystem, ExtendedActorSystem } import akka.event.Logging import akka.persistence.cassandra.session.CassandraSessionSettings import akka.persis...
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:
/* * 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.bstek.designer.editor.palette import com.bstek.designer.core.DoradoToggleEditorModeAction import com.bstek.designer.core.palette.{DoradoPaletteToolWindowContent, DoradoPaletteToolWindowManager} import com.bstek.designer.core.surface.DoradoDesignerEditorPanel import com.bstek.designer.editor.ViewToggleEdito...
Explain and rewrite the following Scala code:
package lila.memo import play.api.mvc.Result import scala.concurrent.duration.FiniteDuration /** only allow X futures at a time per key */ final class FutureConcurrencyLimit[K]( key: String, ttl: FiniteDuration, maxConcurrency: Int = 1, toString: K => String = (k: K) => k.toString )(implicit ec: sca...
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 edu.gemini.spdb.cron import java.util.logging.Logger import java.io.File import java.security.Principal package object osgi { type Env = java.util.Map[String, String] type Job = (File, Logger, Env, java.util.Set[Principal]) => Unit }
Explain and rewrite the following Scala code:
package org.openapitools.server.model /** * @param `class` for example: ''null'' * @param name for example: ''null'' */ final case class Organisation ( `class`: Option[String], name: Option[String] )
Explain and rewrite the following Scala code:
package com.azavea.server.mapalgebra.focal import geotrellis.raster.{CompositeTile, GridBounds, Tile} import geotrellis.spark.{KeyBounds, SpatialComponent, TileLayerMetadata} object Implicits extends Implicits trait Implicits { implicit class withSeqTileComposite(seq: Seq[Tile]) { def runOnSeq[K: SpatialCompon...
Explain and rewrite the following Scala code:
/** * Copyright (C) 2013 Carnegie Mellon University * * 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:
package io.github.yzernik.bitcoinscodec.structures import scodec.Codec import scodec.codecs._ case class TxOut( value: Long, pk_script: Script) object TxOut { implicit val codec: Codec[TxOut] = { ("value" | int64) :: ("pk_script" | Codec[Script]) }.as[TxOut] }
Explain and rewrite the following Scala code:
package com.sksamuel.elastic4s /** @author Stephen Samuel */ sealed abstract class Preference(val elastic: String) object Preference { case class PreferNode(id: String) extends Preference("_prefer_node:" + id) case class OnlyNode(id: String) extends Preference("_only_node:" + id) case class Shards(ids: String*) ...
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 not u...
Explain and rewrite the following Scala code:
package org.scalaide.core package quickassist import org.junit.AfterClass import org.junit.Assert import org.junit.BeforeClass import org.junit.Test import testsetup.SDTTestUtils import org.scalaide.core.internal.quickassist.abstractimpl.ImplAbstractMembers import org.scalaide.core.internal.quickassist.abstractimpl.Ab...
Explain and rewrite the following Scala code:
package mesosphere.marathon.state import com.codahale.metrics.MetricRegistry import mesosphere.marathon.MarathonSpec import mesosphere.marathon.metrics.Metrics import scala.concurrent.{ Await, Future } import scala.concurrent.duration._ import org.mockito.Mockito._ import org.scalatest.Matchers import scala.language.p...
Explain and rewrite the following Scala code:
/* * Copyright 2015 the original author or authors. * @https://github.com/scouter-project/scouter * * 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:
/* * 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 not ...
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 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 2013-2021 David Crosson * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agree...
Explain and rewrite the following Scala code:
package io.argos.agent.sentinels import akka.actor.ActorRef import io.argos.agent.{Messages, SentinelConfiguration} import io.argos.agent.bean.{MetricsRequest, MetricsResponse, _} import io.argos.agent.util.HostnameProvider class ConnectionTimeoutSentinel(val metricsProvider: ActorRef, val conf: SentinelConfiguratio...
Explain and rewrite the following Scala code:
package com.netscout.aion2.source import com.google.inject.{Guice, Module, AbstractModule} import com.netscout.aion2.test.AionMockitoSugar import net.codingwell.scalaguice.ScalaModule import net.codingwell.scalaguice.InjectorExtensions._ import org.mockito.ArgumentMatchers._ import org.mockito.Mockito._ import org.m...
Explain and rewrite the following Scala code:
/** * Licensed to the Minutemen Group under one or more contributor license * agreements. See the COPYRIGHT 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 complian...
Explain and rewrite the following Scala code:
package redeyes.api.http import redeyes.parser._ import redeyes.api._ import redeyes.bytes._ case class Header(name: String, value: String) extends Prerendered { val prerendered = (name.getBytes("US-ASCII") ++ value.getBytes("US-ASCII")).asInstanceOf[ByteArray] } trait RequestHeaders extends ApiModule { import c...
Explain and rewrite the following Scala code:
package com.gilesc package mynab package authentication import cats.data.Validated import cats.data.Validated.{Invalid, Valid} import com.gilesc.mynab.user._ case class Salt(value: String) extends AnyVal case class RawPassword(value: String) extends AnyVal case class HashedPassword(hash: String, salt: Salt) object ...
Explain and rewrite the following Scala code:
package com.karasiq.shadowcloud.streams.index import akka.NotUsed import akka.event.Logging import akka.stream._ import akka.stream.scaladsl.{Flow, Source} import akka.stream.stage.{GraphStage, GraphStageLogic, InHandler, OutHandler} import akka.util.ByteString import com.karasiq.shadowcloud.ShadowCloudExtension impo...
Explain and rewrite the following Scala code:
package pl.arapso.scaffoldings.scala.custom /** * Created by damian on 08.12.16. */ object MapsExamples { def main(args: Array[String]) { var simpleMap = Map("a" -> "b", "c" -> "d") println(simpleMap) simpleMap += ("e" -> "f") println(simpleMap) simpleMap updated ("g", "h") println(sim...
Explain and rewrite the following Scala code:
/* * Copyright 2013-2015 Websudos, Limited. * * 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 of c...
Explain and rewrite the following Scala code:
package org.phenoscape.owlery import com.google.common.base.Optional object Util { implicit class OptionalOption[T](val self: Optional[T]) extends AnyVal { def asScala: Option[T] = if (self.isPresent) Some(self.get) else None } }
Explain and rewrite the following Scala code:
package com.mpc.scalats.core /** * Created by Milosz on 09.06.2016. */ import scala.collection.immutable.ListSet import scala.reflect.runtime.universe._ // TODO: Keep namespace using fullName from the Type final class ScalaParser(logger: Logger) { import ScalaModel._ def parseTypes(types: List[Type]): Lis...
Explain and rewrite the following Scala code:
def factorizer[A, B, C]: (A => C) => (B => C) => Either[A, B] => C = i => j => { case Left(a) => i(a) case Right(b) => j(b) }
Explain and rewrite the following Scala code:
package controllers import play.api.mvc._ import play.api.libs.json.{Json, JsValue} import play.api.libs.iteratee._ import play.api.libs.concurrent.Akka import play.api.Play.current import play.api.libs.concurrent.Execution.Implicits._ import akka.pattern.ask import akka.util.Timeout import akka.actor._ import actors...
Explain and rewrite the following Scala code:
/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software *...
Explain and rewrite the following Scala code:
package com.herokuapp.ochimikan.records.service import akka.actor.Actor import akka.event.Logging import com.herokuapp.ochimikan.directives.{ LoggingDirectives, JwtClaimBuilder, JwtClaimVerifier, JwtDirectives, JwtSignature } import com.herokuapp.ochimikan.json.JwtJson import com.herokuapp.ochimikan.records....
Explain and rewrite the following Scala code:
/* * Copyright 2016 The BigDL 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 agr...
Explain and rewrite the following Scala code:
package org.mellowtech.gapi.store import java.sql.Timestamp import java.time.LocalDateTime import java.time.temporal.{ChronoUnit} import org.mellowtech.gapi.model.TokenResponse import scala.concurrent.{ExecutionContext, Future} case class Token(id: String, access_token: String, token_type: String, ...
Explain and rewrite the following Scala code:
package scala.pickling.pickler import org.scalatest.FunSuite import scala.pickling.internal.HybridRuntime /** * Tests Either picklers */ class EitherPicklerTest extends FunSuite { import scala.pickling._, Defaults._, static._, json._ test("pickle Left") { val l: Left[Int, String] = Left(1) val m = AnyP...
Explain and rewrite the following Scala code:
/* * (c) Copyright 2014 LinkedIn Corp. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by ...
Explain and rewrite the following Scala code:
package com.phasmid.laScala.fp import scala.language.{higherKinds, postfixOps} import scala.util._ /** * This is an 2.11-specific appendix to FP * * @author scalaprof */ object FP_Cross { /** * @param ox the given Option * @param x the value we want to compare with ox * @tparam X the underlyin...
Explain and rewrite the following Scala code:
package satisfaction import org.joda.time.DateTime /** * Information about the result of a single unit of work. * ie. a Single job or script, as compared to the full * goal dependency tree * */ case class ExecutionResult( val executionName : String, val timeStarted: DateTime = DateTime.now) { pri...
Explain and rewrite the following Scala code:
package japgolly.scalajs.react.extra import org.scalajs.dom.raw.EventTarget import org.scalajs.dom.Event import scala.scalajs.js import japgolly.scalajs.react._ import CompScope.DuringCallbackM object EventListener { def apply[E <: Event] = new OfEventType[E](true) def defaultTarget[P, S, B, N <: TopNode]: Duri...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala package lang package psi package impl package base package types import com.intellij.lang.ASTNode import com.intellij.psi._ import com.intellij.util.IncorrectOperationException import org.jetbrains.plugins.scala.extensions._ import org.jetbrains.plugins.scala.lang.completion.lookups...