instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.conversion.copy import com.intellij.codeInsight.editorActions.CopyPastePreProcessor import com.intellij.openapi.project.Project import com.intellij.psi.PsiFile import com.intellij.openapi.editor.{RawText, Editor} import org.jetbrains.plugins.scala.lang.psi.api.ScalaFile import org.j...
Explain and rewrite the following Scala code:
package ujson.util /** * CharBuilder is a specialized way to build Strings. * * It wraps a (growable) array of characters, and can transform * additional String or Char data to be added to its buffer. */ private[ujson] final class CharBuilder { @inline final def INITIALSIZE = 32 private var cs = new Array[Ch...
Explain and rewrite the following Scala code:
package rere.ql.shapes import rere.ql.options.ComposableOptions import rere.ql.options.all._ import rere.ql.ql2.Term.TermType import rere.ql.queries.db.DatabaseQuery import rere.ql.queries.values import rere.ql.types._ abstract class DatabaseShape(private val databaseName: String) { protected def table[ScalaType, K...
Explain and rewrite the following Scala code:
/* Copyright (C) 2008-2016 University of Massachusetts Amherst. This file is part of "FACTORIE" (Factor graphs, Imperative, Extensible) http://factorie.cs.umass.edu, http://github.com/factorie Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with...
Explain and rewrite the following Scala code:
package com.mooneyserver.dublinpubs.rankings.acceptance import play.api.libs.ws.ning.NingWSClient class HealthEndpointSpec extends BaseSpec { info("As a service owner") info("I want to be able to check the health of the service") info("So that I can include this service in the load balancers pool") feat...
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 spark import org.scalatest.FunSuite import org.scalatest.BeforeAndAfter class BroadcastSuite extends FunSuite with BeforeAndAfter { var sc: SparkContext = _ after { if (sc != null) { sc.stop() sc = null } } test("basic broadcast") { sc = new SparkContext("local", "test...
Explain and rewrite the following Scala code:
package com.twitter.scalding import com.twitter.bijection.{AbstractInjection, Injection} import com.twitter.bijection.Inversion._ import com.twitter.elephantbird.cascading2.scheme.LzoTextLine import org.json4s._ import org.json4s.native.Serialization._ import org.json4s.{native, NoTypeHints} import scala.collection....
Explain and rewrite the following Scala code:
/* * Copyright 2016 Combined Conditional Access Development, 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 requir...
Explain and rewrite the following Scala code:
package FloatingPointConverter import scala.math._ import java.lang.{Float => JFloat} object SinglePrecision { private def getDecimalValueOfMantissa(input: String): Double = { var decimalValueOMantissa: Double = 0.0 for (k <- 0 until input.length()) if (input(k) == '1') decimalValueOMantissa += pow(2.0, -1....
Explain and rewrite the following Scala code:
package quizleague.web.maintain.component object TemplateElements { val chbxRetired = """<v-checkbox v-model="item.retired" name="retired" label="Retired"></v-checkbox>""" val formButtons = """ <v-btn fixed dark fab bottom left ...
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.fusesource.cloudmix.agent.snippet import org.fusesource.cloudmix.scalautil.TextFormatting._ import scala.xml._ import scala.collection.JavaConversions._ import java.io.File import org.fusesource.cloudmix.agent.resources.{LogResource, FileSystemResource, DirectoryResource} import org.fusesource.cloudmix.ag...
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:
/** * * 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 m...
Explain and rewrite the following Scala code:
/** * Copyright 2016 Confluent 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 agree...
Explain and rewrite the following Scala code:
package com.twitter.finagle.integration import com.twitter.conversions.time._ import com.twitter.finagle.client.{MethodBuilder, StackClient} import com.twitter.finagle.Http.Http2 import com.twitter.finagle.memcached.protocol.{NoOp, Quit} import com.twitter.finagle.server.StackServer import com.twitter.finagle.util.Has...
Explain and rewrite the following Scala code:
package cc.factorie.directed import cc.factorie.util.FastLogging import cc.factorie.variable.DoubleVariable import org.junit.Test import org.junit.Assert._ import org.scalatest.junit.JUnitSuite class TestGaussian extends JUnitSuite with FastLogging { @Test def testGaussian(): Unit = { val mean = new DoubleVa...
Explain and rewrite the following Scala code:
package ghtorrent import com.mongodb._ import com.mongodb.casbah.commons.MongoDBObject import org.bson.types.ObjectId class MongoDatabase(host: String, port: Int, username: String, password: String, databaseName: String) { private var client: MongoClient = _ private var database: DB = _ private var connected: B...
Explain and rewrite the following Scala code:
package controllers.submodule import javax.inject._ import play.api._ import play.api.mvc._ @Singleton class Application @Inject() extends InjectedController { def index = Action { Ok("Submodule page") } }
Explain and rewrite the following Scala code:
package spire package math package poly import java.lang.Integer.{ numberOfLeadingZeros, numberOfTrailingZeros } import spire.algebra.{Eq, Field, Ring, Rng, Semiring} import spire.math.Polynomial import spire.std.int._ import spire.syntax.field._ import spire.syntax.eq._ import spire.syntax.cfor._ import spire.synta...
Explain and rewrite the following Scala code:
/** * Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0 * See accompanying LICENSE file. */ package kafka.manager import akka.pattern._ import kafka.manager.features.KMDeleteTopicFeature import java.util.concurrent.TimeUnit import com.google.common.cache.{LoadingCache, CacheLoader, CacheBui...
Explain and rewrite the following Scala code:
package daniel.zolnai.marathon.entity /** * Application configuration for sending emails. * Created by Daniel Zolnai on 2016-07-10. */ case class EmailConfig(host: String, port: Int, sender: String, username: Option[String], ...
Explain and rewrite the following Scala code:
package com.joescii import org.scalacheck.{ Properties, Prop } import Prop._ import Generators._ import Solution.palindromes object PalindromeProperties extends Properties("PalindromeProperties") { def isPalindrome(s: String): Boolean = { val l = s.length / 2 s.take(l) == s.takeRight(l).reverse } prop...
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 * distributed under the...
Explain and rewrite the following Scala code:
/* ************************************************************************************* * Copyright 2014 Normation SAS ************************************************************************************* * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero Ge...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2012-2015 Snowplow Analytics Ltd. All rights reserved. * * This program is licensed to you under the Apache License Version 2.0, * and you may not use this file except in compliance with the Apache License Version 2.0. * You may obtain a copy of the Apache License Version 2.0 at http://www.apach...
Explain and rewrite the following Scala code:
package sext import util.Try import reflect.runtime.universe._ import reflect.runtime.currentMirror import collection.GenTraversableOnce object `package` { implicit class SextMap [ A, B ] ( val a : Map[ A, B ] ) extends AnyVal { def filterValues(predicate: B => Boolean) = a.filter(pair => predicate(pair....
Explain and rewrite the following Scala code:
package chee.cli import org.scalatest._ import chee.it._ class CollectionTest extends FlatSpec with Matchers with CommandSetup { def collRemove = new CollectionRemove with BufferOut def collEdit = new CollectionEdit with BufferOut def collShow = new CollectionShow with BufferOut "collection add" should "add...
Explain and rewrite the following Scala code:
import org.apache.spark._ import org.apache.spark.streaming._ import org.apache.spark.streaming.StreamingContext._ import org.apache.spark.SparkContext import org.apache.spark.SparkContext._ import InstrumentParameters._ import StockOptionPricing._ object StockOptionMarketRisk { val shiftSize = 0.001 val riskFreeR...
Explain and rewrite the following Scala code:
package ru.wordmetrix.nlp object NLP { type Phrase = String type Word = String implicit def string2NLP(s: String) = new NLP(s) implicit def list2NLP(l: List[String]) = new NLP(l) implicit def list2String(l: List[String]) = l.rectify() implicit def nlp2String(nlp: NLP) = nlp.phrase.rectify() ...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2014 - 2016 Softwaremill <http://softwaremill.com> * Copyright (C) 2016 - 2019 Lightbend Inc. <http://www.lightbend.com> */ package akka.kafka import org.apache.kafka.common.errors.TimeoutException final case class KafkaConnectionFailed(te: TimeoutException, attempts: Int) extends Exception...
Explain and rewrite the following Scala code:
package com.karasiq.nanoboard.sources.bitmessage import play.api.libs.json.Json import com.karasiq.nanoboard.NanoboardMessage @SerialVersionUID(0L) private[bitmessage] final case class WrappedNanoboardMessage(hash: String, message: String, replyTo: String) { assert(hash.length == NanoboardMessage.HashLength && rep...
Explain and rewrite the following Scala code:
package com.twitter.finagle.stream import com.twitter.finagle.netty3.{BufChannelBuffer, ChannelBufferBuf} import com.twitter.io.Buf case class StreamRequest( method: StreamRequest.Method, uri: String, version: Version = Version(1, 1), headers: Seq[Header] = Nil, body: Buf = Buf.Empty ) object Str...
Explain and rewrite the following Scala code:
package moe.pizza.auth.webapp.rest import moe.pizza.auth.config.ConfigFile.{AuthConfig, ConfigFile} import moe.pizza.auth.graphdb.EveMapDb import moe.pizza.auth.interfaces.{BroadcastService, PilotGrader, UserDatabase} import moe.pizza.auth.models.Pilot import moe.pizza.auth.tasks.Update import moe.pizza.crestapi.Crest...
Explain and rewrite the following Scala code:
package scala.collection.mutable import java.util.concurrent.TimeUnit import org.openjdk.jmh.annotations._ import scala.collection.mutable @BenchmarkMode(Array(Mode.AverageTime)) @Fork(1) @Threads(1) @Warmup(iterations = 6) @Measurement(iterations = 6) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Benchmark) c...
Explain and rewrite the following Scala code:
package domino.logging import domino.service_consuming.ServiceConsuming /** * A class that mixes in the [[Logging]] trait. Use this if you want to use a class instead of a trait. */ class SimpleLogging(protected val serviceConsuming: ServiceConsuming) extends Logging
Explain and rewrite the following Scala code:
package geotrellis.util import geotrellis.spark.etl.config.{AccumuloPath, AccumuloProfile} trait AccumuloSupport extends BackendSupport { lazy val accumuloOutputPath = etlConf.output.backend.path match { case p: AccumuloPath => p case p => throw new Exception(s"Not valid output AccumuloPath: ${p}") } @...
Explain and rewrite the following Scala code:
package org.broadinstitute.dsde.workbench.sam.db.tables import org.broadinstitute.dsde.workbench.model.WorkbenchUserId import org.broadinstitute.dsde.workbench.sam.db.{DatabaseKey, SamTypeBinders} import scalikejdbc._ final case class GroupMemberPK(value: Long) extends DatabaseKey final case class GroupMemberRecord(i...
Explain and rewrite the following Scala code:
package org.igye.jfxutils.events import javafx.event.{Event, EventHandler, EventType} import javafx.scene.Scene import javafx.scene.input.KeyEvent import org.igye.jfxutils.Implicits.sceneToSceneOps import org.igye.jfxutils.action.ActionType.{FILTER, HANDLER} import org.igye.jfxutils.action.{Action, ShortcutActionTrig...
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.apache.spot.dns import org.apache.spot.testutils.TestingSparkContextFlatSpec import org.apache.spot.utilities.Entropy import org.scalatest.Matchers class DNSWordCreationTest extends TestingSparkContextFlatSpec with Matchers { "entropy" should "return 2.807354922057603 with value abcdefg" in { val...
Explain and rewrite the following Scala code:
/** * Copyright 2009 Google 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 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...
Explain and rewrite the following Scala code:
package drt.client.components import diode.data._ import drt.client.UserDeskRecFixtures._ import drt.client.components.Heatmap.Series import drt.client.services.{DeskRecTimeSlots, Shift, ShiftService} import drt.client.services.JSDateConversions.SDate import drt.shared.FlightsApi.QueueName import drt.shared._ import u...
Explain and rewrite the following Scala code:
/* * Copyright 2012-2020 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 ap...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014-2021 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 parsing.backtrack import parsing.UnitSpec /** * Created by hongdi.ren. */ class BacktrackParserTest extends UnitSpec { "BacktrackParser" should "throw exception for incorrect input" in { val lexer = new BacktrackLexer("[a,b]=[c,d,,]") val parser = new BacktrackParser(lexer) val e = the[Exce...
Explain and rewrite the following Scala code:
package breeze.util /* Copyright 2012 David Hall Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
Explain and rewrite the following Scala code:
package com.gu.release import com.typesafe.sbt.SbtGit.git import com.typesafe.sbt.git.ConsoleGitRunner import com.typesafe.sbt.pgp.PgpKeys import sbt.Keys._ import sbt._ import xerial.sbt.Sonatype import xerial.sbt.Sonatype.SonatypeCommand object ShipAutoPlugin extends AutoPlugin { //Declare dependencies on other ...
Explain and rewrite the following Scala code:
package kuyfi import java.util.{ List => JList, Map => JMap, Set => JSet } import scala.jdk.CollectionConverters._ object JDKConv { def toJava[A, B](m: Map[A, B]): JMap[A, B] = m.asJava def toJava[A](m: List[A]): JList[A] = m.asJava def toScala[A](m: JSet[A]): Set[A] = m.asScala.toSet }
Explain and rewrite the following Scala code:
/* * Copyright (c) 2021, salesforce.com, inc. * All rights reserved. * SPDX-License-Identifier: BSD-3-Clause * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ package com.krux.hyperion.activity import com.krux.hyperion.HyperionContext import com.kru...
Explain and rewrite the following Scala code:
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** @author John Miller * @version 1.3 * @date Mon Sep 21 15:05:06 EDT 2009 * @see LICENSE (MIT style license file). */ package scalation.animation import scala.collection.mutable.{HashSet, ListBuffer} import scala.math.a...
Explain and rewrite the following Scala code:
package com.github.diegopacheco.scala.akkastreams object TimeBasedProcessingMain extends App { import akka.stream._ import akka.stream.scaladsl._ import akka.{ NotUsed, Done } import akka.actor.ActorSystem import akka.util.ByteString import scala.concurrent._ import scala.concurrent.duration._ imp...
Explain and rewrite the following Scala code:
package com.tonybeltramelli.desktop.core.scoring import com.tonybeltramelli.desktop.util.Helper class LanguageBasedScoring extends AScoring { override def getScore(f: (Map[String, Int], Int), query: List[String]) : Double = { val lambda : Double = 0.1 //0.1 for title queries and 0.7 for long queries, Jelinek-M...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
/* * Part of NDLA article-api. * Copyright (C) 2018 NDLA * * See LICENSE */ package db.migration import java.sql.Connection import org.flywaydb.core.api.migration.{BaseJavaMigration, Context} import org.json4s.Extraction.decompose import org.json4s.JsonAST.JArray import org.json4s.native.JsonMethods.{compact, p...
Explain and rewrite the following Scala code:
package io.questions.testdata import java.util.UUID import cats.data.NonEmptyList import io.questions.model.questionnaire.Element.Primitive import io.questions.model.questionnaire.Path.root import io.questions.model.questionnaire.PrimitiveAnswer.{ EnumerationAnswer, StringAnswer } import io.questions.model.questionna...
Explain and rewrite the following Scala code:
package slinky.web import slinky.core.SyntheticEvent import scala.scalajs.js import org.scalajs.dom.AnimationEvent // https://reactjs.org/docs/events.html?#animation-events @js.native trait SyntheticAnimationEvent[+TargetType] extends SyntheticEvent[TargetType, AnimationEvent] { val animationName: String = js.nati...
Explain and rewrite the following Scala code:
package org.jetbrains.sbt.project.template import com.intellij.ide.util.projectWizard.ModuleBuilder import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalModuleBuilder import com.intelli...
Explain and rewrite the following Scala code:
package com.acme.sausage import akka.actor.Actor import spray.routing._ import spray.http.StatusCodes._ import org.json4s._ import spray.httpx.Json4sSupport class ExtractAndRunServiceActor(val service: Extractor) extends Actor with ExtractAndRunService { def actorRefFactory = context def receive = runRoute(restR...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2012-2015 Snowplow Analytics Ltd. All rights reserved. * * This program is licensed to you under the Apache License Version 2.0, * and you may not use this file except in compliance with the Apache License Version 2.0. * You may obtain a copy of the Apache License Version 2.0 at http://www.apach...
Explain and rewrite the following Scala code:
package glaux.persistence.mongodb import java.time.ZonedDateTime import glaux.interfaces.api.domain._ import glaux.persistence.mongodb.GeneralHandlers._ import org.specs2.mutable.Specification import reactivemongo.bson._ import play.api.libs.functional._ import syntax._ case class TestCase(readings: Vector[(Seq[Doub...
Explain and rewrite the following Scala code:
package org.scalajs.jsenv.test import org.scalajs.jsenv.rhino._ import org.scalajs.core.tools.sem._ class RhinoJSEnvTest extends TimeoutComTests { protected def newJSEnv = new RhinoJSEnv(Semantics.Defaults) }
Explain and rewrite the following Scala code:
package de.holisticon.showcase.ticketbooking.service import akka.actor.{ ActorLogging, ActorRef, Actor } import akka.http.scaladsl.Http import akka.http.scaladsl.model.HttpEntity.Strict import akka.http.scaladsl.model._ import akka.http.scaladsl.model.headers.Location import akka.stream.Materializer import akka.util.{...
Explain and rewrite the following Scala code:
package com.shocktrade.controlpanel.runtime.functions package builtin import com.shocktrade.controlpanel.runtime.{RuntimeContext, Scope, TextValue} import io.scalajs.JSON import io.scalajs.npm.request.Request import io.scalajs.util.PromiseHelper.Implicits._ import scala.concurrent.{ExecutionContext, Future} /** * ...
Explain and rewrite the following Scala code:
package edu.berkeley.nlp.summ import java.io.File import scala.collection.mutable.ArrayBuffer import edu.berkeley.nlp.entity.GUtil import edu.berkeley.nlp.entity.coref.MentionPropertyComputer import edu.berkeley.nlp.entity.coref.NumberGenderComputer import edu.berkeley.nlp.entity.coref.PairwiseScorer import edu.berkel...
Explain and rewrite the following Scala code:
package core.common import com.ning.http.client.AsyncHttpClientConfig import play.api.libs.concurrent.Execution.Implicits._ import play.api.libs.functional.syntax._ import play.api.libs.json.Json.JsValueWrapper import play.api.libs.json._ import play.api.libs.ws.{DefaultWSClientConfig, WS} import play.api.libs.ws.ning...
Explain and rewrite the following Scala code:
package kipsigman.domain.service import java.net.{ URLDecoder, URLEncoder } import scala.util.matching.Regex trait UrlUtils { // Regex val UrlRegex: Regex = """(https?|ftp|file|mailto)://[-A-Za-z0-9+&@#/%?=~_|!:,.;\{\}]*[-A-Za-z0-9+&@#/%=~_|\{\}]""".r val UrlMatchRegex: Regex = ("^" + UrlRegex.toString + "$...
Explain and rewrite the following Scala code:
package se.culvertsoft.mgen.cpppack.generator.impl.classh import se.culvertsoft.mgen.api.model.ClassType import se.culvertsoft.mgen.compiler.util.SourceCodeBuffer object MkDestructor { def apply(t: ClassType)(implicit txtBuffer: SourceCodeBuffer) { txtBuffer.tabs(1).textln(s"virtual ~${t.shortName()}();") ...
Explain and rewrite the following Scala code:
// 1EC Graph Parser // Copyright (c) University of California // Copyright (c) Jonathan Kummerfeld // // This software is covered by a license. See the LICENSE.txt file in the // top-level directory of this distribution or at // https://github.com/jkkummerfeld/1ec-graph-parser for the full text of the // license. pac...
Explain and rewrite the following Scala code:
import scala.of.coq.lang._ import Nat._ import Pairs._ import Bools._ import MoreLists._ import scala.concurrent.Future import MoreFutures._ object FutureMergeSort { def split[A](l: List[A]): (List[A], List[A]) = l match { case Nil => (Nil, Nil) case x :: Nil => (x :: Nil, Nil) case x :: y :: xs...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2016 Language Technology Group and Interactive Graphics Systems Group, Technische Universität Darmstadt, Germany * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, ...
Explain and rewrite the following Scala code:
object GoodCoverage { def sum(num1: Int, num2: Int) = { num1 + num2 } }
Explain and rewrite the following Scala code:
package me.shreyasr.starfighter import java.util.ArrayList import com.badlogic.ashley.core.EntitySystem import me.shreyasr.starfighter.event.{Event, EventQueue} import scala.collection.JavaConversions._ class EventQueueNetworkUpdater(priority: Int, eventQueue: EventQueue, newEvents: ArrayList[Event]) extends Enti...
Explain and rewrite the following Scala code:
/* * * /\\\\\\\\\\ * /\\\\\\///\\\\\\ * /\\\\\\/ \\///\\\\\\ /\\\\\\\\\\\\\\\\\\ /\\\\\\ /\\\\\\ * /\\\\\\ \\//\\\\\\ /\\\\\\/////\\\\\\ /\\\\\\\\\\\\\\\\\\\\\\ \\/// /\\\\\\\\\\ /\\\\\\\\\\ /\\\\\\ /\\\\\\ /\\\\\\\\\\\\\\\\\\\\ * \\/\\\\\\ \\/\\\\\\ \\/\\\\\\\\\\\\\\\\\\\...
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 japgolly.scalajs.react.core import scalajs.js import scalajs.js.annotation._ import utest._ import japgolly.scalajs.react._ import japgolly.scalajs.react.test.ReactTestUtils import japgolly.scalajs.react.test.TestUtil._ object JsFnComponentTest extends TestSuite { @JSGlobal("FnComp") @js.native object R...
Explain and rewrite the following Scala code:
package glasskey.spray.client import akka.actor.ActorRefFactory import spray.routing._ /** * Created by loande on 12/5/2014. */ class HelloWorldClientCredentialsClientService(actorRefFactory: ActorRefFactory) extends SampleClientService(actorRefFactory) { override def helloWorldRoute(implicit env: SprayClientRunti...
Explain and rewrite the following Scala code:
package com.twitter.finatra.http.internal.marshalling.mustache import com.google.common.net.MediaType import com.twitter.finatra.conversions.map._ import com.twitter.finatra.http.marshalling.{MessageBodyWriter, WriterResponse} import com.twitter.finatra.response.Mustache import java.util.concurrent.ConcurrentHashMap i...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2013-2022 Erik van Oosten * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law ...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014-2016 Snowplow Analytics Ltd. All rights reserved. * * This program is licensed to you under the Apache License Version 2.0, * and you may not use this file except in compliance with the Apache License Version 2.0. * You may obtain a copy of the Apache License Version 2.0 at http://www.apach...
Explain and rewrite the following Scala code:
package excavators.odesk.apps.searcher import excavators.odesk.db.ODeskExcavatorsDBProvider import excavators.odesk.ui.{ExcavatorUI, Browser} import util.logging.{ToDBAndConsoleLogger, SimpleLogger} /** * oDesk job searcher * Created by CAB on 21.09.14. */ object Main { //Create components val l = new ToDBAndCon...
Explain and rewrite the following Scala code:
package structures import java.awt.Color import java.util.Random /** Class that provides several frequently used methods across classes * @author Sean Lewis */ object CalcHelp { private val randomGenerator = new Random /** Rounds a Double precision value to an Integer. */ def round(x: Double): Int = mat...
Explain and rewrite the following Scala code:
package me.yingrui.segment.neural import java.lang.Math.abs import me.yingrui.segment.math.Matrix trait BackPropagationLayer extends Layer { def update(rate: Double, momentum: Double) def propagateError(delta: Matrix): Matrix def calculateDelta(actual: Matrix, error: Matrix): Matrix def layer: Layer v...
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.coursera.naptime import com.linkedin.data.schema.ArrayDataSchema import com.linkedin.data.schema.DataSchema import com.linkedin.data.schema.DataSchemaUtil import com.linkedin.data.schema.MapDataSchema import com.linkedin.data.schema.RecordDataSchema import com.linkedin.data.schema.UnionDataSchema import or...
Explain and rewrite the following Scala code:
package models.consul import play.api.libs.json.Json case class HealthInfo( Node: NodeInfo, Service: ServiceInfo, Checks: Seq[CheckInfo] ) object HealthInfo { implicit val jsonFormat = Json.format[HealthInfo] }
Explain and rewrite the following Scala code:
package org.template.similar import io.prediction.controller.IEngineFactory import io.prediction.controller.Engine case class Query( val items: List[String], val num: Int, val categories: Option[Set[String]], val whiteList: Option[Set[String]], val blackList: Option[Set[String]] ) extends Serializable case...
Explain and rewrite the following Scala code:
package jellies.game.metadata import jellies.game.LevelMetadata case object NoAutoSolve extends LevelMetadata
Explain and rewrite the following Scala code:
/******************************************************************************* Copyright (c) 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:
package org.raisercostin.jedi.impl import scala.util.{Try,Failure,Success} import scala.util.Properties object ProcessUtils extends SlfLogger{ /**Inspired from here: http://winaero.com/blog/symbolic-link-in-windows-10 */ def executeWindows(command: Seq[String]):Try[Unit] = { require(Properties.isWin) Sl...
Explain and rewrite the following Scala code:
package nvim /** * Thrown by the Nvim integration logic whenever Nvim sends an unexpected * response. */ final class UnexpectedResponse(response: String) extends RuntimeException(response)
Explain and rewrite the following Scala code:
package ch.wsl.box.codegen import slick.model.{Column, Model} import ch.wsl.box.jdbc.PostgresProfile.api._ import scala.concurrent.Await import scala.concurrent.duration.DurationInt case class FixFileAccesGenerator(model:Model,_tables:Seq[String]) extends slick.codegen.SourceCodeGenerator(model) with BoxSourceCo...
Explain and rewrite the following Scala code:
package dk.itu.wsq.cases.quicksort import dk.itu.wsq._ import scala.util.Random object QuickSortNode { def insertionSort(arr: Array[Int]): Unit = { //println("Insertion sort") var x = 0 var j = 0 for (i <- 0 until arr.length) { x = arr(i) j = i while (j > 0 && arr(j - 1) > x) { ...
Explain and rewrite the following Scala code:
package com.bostontechnologies.quickfixs.messages import quickfix.Message import quickfix.fixt11.Reject import quickfix.field._ class RichSessionReject private(self: Message) extends RichMessage(self) { require(RichMessage.isA(self, RichSessionReject.msgType)) def refMessageSequenceNumber: Int = self.getInt(R...
Explain and rewrite the following Scala code:
/* *\\ ** Squants ** ** ** ** Scala Quantities and Units of Measure Library and DSL ** ** (c) 2013-2015, G...
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...