instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
package filter import play.api.mvc.{SimpleResult, RequestHeader, Filter} import scala.concurrent.Future /** * The Class ProfilingFilter. * * @author Nguyen Duc Dung * @since 2/13/14 4:41 PM * */ object ProfilingFilter extends Filter { val warningTime = 1000 //ms def apply(next: (RequestHeader) => Future[S...
Explain and rewrite the following Scala code:
package org.tinydvr.util import akka.actor._ object Singletons { // note: ActorSystem is a heavyweight structure... so create one per logical application. lazy val actorSystem = ActorSystem("tinydvr") }
Explain and rewrite the following Scala code:
/*ref*/mutable.ArrayBuffer /* import scala.collection.mutable /*ref*/mutable.ArrayBuffer */
Explain and rewrite the following Scala code:
package com.twitter.finatra.http.request import com.twitter.finagle.http.{Request, RequestProxy} private[http] class ForwardedRequest(wrapped: Request, path: String) extends RequestProxy { def request: Request = wrapped /** * Returns the URI of this request. */ override def uri: String = path }
Explain and rewrite the following Scala code:
package io.github.tailhq.dynaml.graphics.charts import highcharts._ import repl._ import scala.collection.immutable.ListMap import scala.language.implicitConversions /** * User: austin * Date: 12/2/14 * * Highcharts implementation of plotting functionality. Includes several highcharts specific plots * * I rely on the...
Explain and rewrite the following Scala code:
package models import play.api.db._ import play.api.Play import play.api.Play.current import org.squeryl.{PrimitiveTypeMode, Session, SessionFactory} import org.squeryl.adapters.{H2Adapter, MySQLInnoDBAdapter} import org.squeryl.logging.{LocalH2SinkStatisticsListener, StatsSchema} import java.io.File import java.sql...
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 geotrellis.run import com.beust.jcommander._ import scala.collection._ // Command line tool to run geotrellis tasks. // Use wrapper script or "start-script" task to create start script to run in sbt directory, e.g: // ./target/start geotrellis.run.Tasks geotiff_convert -i src/test/resources/econic.tif -n ...
Explain and rewrite the following Scala code:
package classification import ModelType._ import utilities.DoubleVector class LocalModel( val weights: Array[Double], val lags: Array[Double], val gamma: Double) extends Serializable { def getWeightedPara(map: Array[Int], numFeatures: Int): DoubleVector = { val weightedPara = new Array[Double...
Explain and rewrite the following Scala code:
/* * @author Philip Stutz * * Copyright 2011 University of Zurich * * 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....
Explain and rewrite the following Scala code:
package sangria.schema case class SchemaMaterializationException(message: String, cause: Throwable = null) extends Exception(message, cause) case class InputMaterializationException(message: String) extends Exception(message)
Explain and rewrite the following Scala code:
/* Copyright 2009-2021 EPFL, Lausanne */ package stainless package extraction package oo trait SymbolOps extends TypeOps with innerfuns.SymbolOps { self => import trees._ import symbols.{given, _} /** Converts the pattern applied to an input to a map between identifiers and expressions */ override def mapFor...
Explain and rewrite the following Scala code:
/* * bytefrog: a tracing framework for the JVM. For more information * see http://code-pulse.com/bytefrog * * Copyright (C) 2014 Applied Visions - http://securedecisions.avi.com * * 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:
package com.sksamuel.elastic4s.requests.searches.aggs import com.sksamuel.elastic4s.requests.common.RefreshPolicy import com.sksamuel.elastic4s.requests.searches.DateHistogramInterval import com.sksamuel.elastic4s.testkit.DockerTests import org.scalatest.freespec.AnyFreeSpec import org.scalatest.matchers.should.Matche...
Explain and rewrite the following Scala code:
It's because `foldRight`, `foldLeft`, and `foldMap` don't give us any way of constructing a value of the foldable type. In order to `map` over a structure, you need the ability to create a new structure (such as `Nil` and `Cons` in the case of a `List`). `Traverse` is able to extend `Functor` precisely because a traver...
Explain and rewrite the following Scala code:
package org.kanyec.ast import org.objectweb.asm.MethodVisitor import org.objectweb.asm.Opcodes._ import org.objectweb.asm.Label import org.kanyec.SymbolTable case class EqualToNode(operand1: AstNode, operand2: AstNode) extends ExpressionNode { def generate(mv: MethodVisitor, symbolTable: SymbolTable) { val not...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2015 Cotiviti Labs (nexgen.admin@cotiviti.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless req...
Explain and rewrite the following Scala code:
package dazzle.waffle import dazzle.waffle.adapter.Adapter import java.io.InputStream import java.nio.file.{Path, Files} import org.junit.runner.RunWith import org.specs2.mutable.Specification import org.specs2.mock.Mockito import org.specs2.runner.JUnitRunner import scala.util.Success @RunWith(classOf[JUnitRunner]) ...
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 Twitter. 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 applicable ...
Explain and rewrite the following Scala code:
package com.rockymadden.stringmetric.similarity import com.rockymadden.stringmetric.{StringMetric, MatchTuple, StringFilter} import com.rockymadden.stringmetric.tokenization.NGramTokenizer import scala.math /** An implementation of the N-Gram metric. */ class NGramMetric extends StringMetric[Int, Double] { this: Stri...
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 filodb.core import com.typesafe.scalalogging.StrictLogging import org.scalactic.Explicitly import org.scalatest._ import org.scalatest.concurrent.{Eventually, IntegrationPatience, ScalaFutures} import org.scalatest.time.{Millis, Seconds, Span} import org.scalatest.matchers.should.Matchers import org.scalatest....
Explain and rewrite the following Scala code:
/* * Copyright 2012-2013 Stephane Godbillon (@sgodbillon) and Zenexity * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless req...
Explain and rewrite the following Scala code:
/* * 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:
package ch.becompany.model abstract sealed class Role(val id: String) { override def toString() = id } case object Corporal extends Role("corporal") case object Sergeant extends Role("sergeant") case object Captain extends Role("captain") case object Commander extends Role("commander") object Role { def parse(rol...
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 coursier.cli.setup import caseapp.core.parser.Parser import caseapp.{Name => Short, Recurse} import coursier.cli.install.{SharedChannelOptions, SharedInstallOptions} import coursier.cli.jvm.SharedJavaOptions import coursier.cli.options.{CacheOptions, EnvOptions, OutputOptions, RepositoryOptions} // format: of...
Explain and rewrite the following Scala code:
/* * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
Explain and rewrite the following Scala code:
package one.lockstep package util package codec import scodec._ import scodec.codecs._ trait LimitedSizeCodecsModule { thisModule: FixedSizeCodecsModule => sealed trait SizeCodec object SizeCodec { case class Bytes(sizeCodec: Codec[Int] = uint16) extends SizeCodec case class Bits(sizeCodec: Codec[Int] = u...
Explain and rewrite the following Scala code:
package io.github.davepkennedy.bark.state import akka.actor.{ActorSystem, Props} import akka.testkit.{ImplicitSender, TestFSMRef, TestKit} import io.github.davepkennedy.bark.ui.Displayable import org.scalatest.{BeforeAndAfterAll, FreeSpecLike, Matchers} import io.github.davepkennedy.bark._ class CandidateStub (val i...
Explain and rewrite the following Scala code:
// Copyright (c) 2012 Cloudera, Inc. 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 applica...
Explain and rewrite the following Scala code:
package sttp.client3.jsoniter import org.scalatest.EitherValues import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers import sttp.client3._ import sttp.client3.internal.Utf8 import sttp.model._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.github.plokhotnyuk.jsoniter...
Explain and rewrite the following Scala code:
package hello trait stuff { type Numb = Int val magic = 42 } object world { val potions = new stuff {} }
Explain and rewrite the following Scala code:
package io.github.suitougreentea.VariousMinos.game /*class GameContest(parent: GameWrapper) extends Game with GameWrapper { val game = GameBomb(this, defa) }*/
Explain and rewrite the following Scala code:
package debop4s.core.jodatime import org.joda.time.ReadableDuration class JodaRichReadableDuration(val self: ReadableDuration) extends AnyVal with Ordered[ReadableDuration] { def millis: Long = self.getMillis def compare(that: ReadableDuration): Int = self.compareTo(that) }
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:
// Generated by <a href="http://scalaxb.org/">scalaxb</a>. package eveapi.xml.account.map.Kills import scala.concurrent.Future /** usage: val obj = scalaxb.fromXML[eveapi.xml.account.map.Kills.Foo](node) val document = scalaxb.toXML[eveapi.xml.account.map.Kills.Foo](obj, "foo", eveapi.xml.account.map.Kills.defaultSc...
Explain and rewrite the following Scala code:
package eu.timepit.crjdt.circe import eu.timepit.crjdt.core.Replica import eu.timepit.crjdt.core.syntax._ import eu.timepit.crjdt.circe.syntax._ import eu.timepit.crjdt.circe.testUtil.{converged, diverged, merge} import io.circe.Json import org.scalacheck.Prop._ import org.scalacheck.Properties object NodeToJsonFigur...
Explain and rewrite the following Scala code:
/* * Copyright 2013 Gregor Uhlenheuer * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed...
Explain and rewrite the following Scala code:
package test.scala.com.skene.matcher import org.specs2.mutable._ import org.specs2.mock.Mockito import com.roundeights.skene._ class PathTest extends Specification with Mockito { val request = mock[Request]; request.url returns URL("http://example.com/path/to/resource") "A Path matcher without wildcard...
Explain and rewrite the following Scala code:
package scala.models import scala.generator.ScalaService import org.scalatest.{ ShouldMatchers, FunSpec } class JsonImportsSpec extends FunSpec with ShouldMatchers { it("basic service") { JsonImports(models.TestHelper.referenceApiService) should be( Seq( "import com.bryzek.apidoc.reference.api.v0...
Explain and rewrite the following Scala code:
package com.linkedin.norbert package network package common import java.util.concurrent.atomic.AtomicLong import java.util.{Map => JMap} import com.linkedin.norbert.cluster.Node import com.linkedin.norbert.jmx.JMX import com.linkedin.norbert.jmx.JMX.MBean import com.linkedin.norbert.norbertutils.Clock import scala.c...
Explain and rewrite the following Scala code:
/*********************************************************************** * Copyright (c) 2013-2022 Commonwealth Computer Research, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Apache License, Version 2.0 * which accompanies this distribution and...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.lang.transformation package calls import com.intellij.psi.PsiElement import org.jetbrains.plugins.scala.extensions.{&&, Parent, ReferenceTarget} import org.jetbrains.plugins.scala.lang.psi.api.base.ScFieldId import org.jetbrains.plugins.scala.lang.psi.api.base.patterns.ScReferencePa...
Explain and rewrite the following Scala code:
package baz object Foo { def bar: String = "hello" }
Explain and rewrite the following Scala code:
package exercises.ch03 object Ex10 { def main(args: Array[String]): Unit = { // foldLeft was added to the List companion object } }
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:
import java.math.BigInteger object Hello { def main(args: Array[String]): Unit = { println("Hello, world!") println(factorial2(BigInteger.valueOf(10))) var name = "frf" val nameHasUpperCase = name.exists(_.isUpper) println(nameHasUpperCase) println(max2(3,7)) } // def factorial(x: BigIn...
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.ecfront.ez.framework.service.auth.manage import com.ecfront.common.Resp import com.ecfront.ez.framework.core.rpc._ import com.ecfront.ez.framework.service.auth.model.EZ_Account import com.ecfront.ez.framework.service.jdbc.scaffold.SimpleRPCService import com.ecfront.ez.framework.service.jdbc.{BaseStorage, ...
Explain and rewrite the following Scala code:
/* Copyright 2014 NICTA This file is part of t3as (Text Analysis As A Service). t3as 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 optio...
Explain and rewrite the following Scala code:
/* * SPDX-License-Identifier: Apache-2.0 * * Copyright 2015-2021 Andre White. * * 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 * * https://www.apache.org/licenses/LICENSE...
Explain and rewrite the following Scala code:
package org.powlab.jeye.decode.pattern.ternary import scala.collection.mutable.ArrayBuffer import org.powlab.jeye.decode.graph.GroupOpcodeNode import org.powlab.jeye.decode.graph.OpcodeNode import org.powlab.jeye.decode.graph.OpcodeTree import org.powlab.jeye.decode.pattern.LogicPatterns.LogicPattern import org.powla...
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 mesosphere.marathon package core.storage.store import java.time.OffsetDateTime /** * Resolver for Marathon Internal Persistence IDs (by `Key Type`, `Value Type` and `Serialized Type`) * For example, Applications may be identified by the string "/apps/abc" and stored internally at * "/apps/a/a58ec17d-735...
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 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:
import org.apache.spark.sql.simba.{Dataset, SimbaSession} import org.apache.spark.sql.simba.index.RTreeType import scala.collection.mutable.ListBuffer import scala.collection.mutable.HashMap import org.slf4j.{Logger, LoggerFactory} import org.scalameter._ import org.apache.spark.sql.functions._ import scala.collection....
Explain and rewrite the following Scala code:
package controllers import org.specs2.mutable._ import utils.WithBrowser class CookiesIntegrationSpec extends Specification { section("unit") "Cookies pages should" should { "cookies will be presented in English by default" in new WithBrowser { browser.goTo("/cookies/en") browser.pageSource() must...
Explain and rewrite the following Scala code:
// Generated by the Scala Plugin for the Protocol Buffer Compiler. // Do not edit! // // Protofile syntax: PROTO2 package com.google.protobuf.descriptor /** Describes the relationship between generated code and its original source * file. A GeneratedCodeInfo message is associated with only one generated * source ...
Explain and rewrite the following Scala code:
/** * Copyright (C) 2011 - 101loops.com <dev@101loops.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by appli...
Explain and rewrite the following Scala code:
/* * Copyright 2001-2009 Stephen Colebourne * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable...
Explain and rewrite the following Scala code:
/* * Copyright © 2015 - 2019 Lightbend, Inc. <http://www.lightbend.com> * * 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 requ...
Explain and rewrite the following Scala code:
/* * Pragma.scala * Pragmas: hints to algorithms. * * Created By: Avi Pfeffer (apfeffer@cra.com) * Creation Date: Jan 1, 2009 * * Copyright 2013 Avrom J. Pfeffer and Charles River Analytics, Inc. * See http://www.cra.com or email figaro@cra.com for information. * * See http://www.github.com/p2t2/fig...
Explain and rewrite the following Scala code:
package it.nerdammer.spark.hbase import it.nerdammer.spark.hbase.conversion.FieldReader import org.apache.hadoop.hbase.CellUtil import org.apache.hadoop.hbase.client.Result import org.apache.hadoop.hbase.io.ImmutableBytesWritable import org.apache.hadoop.hbase.util.Bytes import org.apache.spark.rdd.{NewHadoopRDD, RDD}...
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.delprks.productservicesprototype.api.directives import com.delprks.productservicesprototype.api.directives.ResponseDirectives.MultiEntityResponseData import com.delprks.productservicesprototype.api.params.Paginate import com.delprks.productservicesprototype.domain.response.{Responses, SingleResponse} impo...
Explain and rewrite the following Scala code:
package sclack.domain.commands /** * Transaction that holds everything when using an item in game. * @author Simon Symeonidis */ class UseItem extends Commandable { /** Use the item, waste a turn */ def execute() { } }
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala package lang.psi.implicits import com.intellij.openapi.progress.ProgressManager import com.intellij.psi._ import com.intellij.psi.util.PsiTreeUtil import com.intellij.util.containers.ConcurrentHashMap import org.jetbrains.plugins.scala.caches.ScalaRecursionManager import org.jetbrai...
Explain and rewrite the following Scala code:
package com.outr.arango class WrappedRef[T](val wrapped: T, val refName: Option[String] = None) extends Ref
Explain and rewrite the following Scala code:
package com.alanjz.xcube.moves trait Move { def inverse : Move } trait IdentityMove extends Move { override def inverse = this }
Explain and rewrite the following Scala code:
package com.twitter.finagle.service /** * A classification of the result of a request/response pair. * * @see [[ResponseClassifier]] */ sealed abstract class ResponseClass { /** * Accomodates responses that can be partially successful. * * Determining a fractional value will typically require the serve...
Explain and rewrite the following Scala code:
/** * Swaggy Jenkins * Jenkins API clients generated from Swagger / Open API specification * * The version of the OpenAPI document: 1.1.2-pre.0 * Contact: blah@cliffano.com * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not ed...
Explain and rewrite the following Scala code:
package springrtsru.model import java.util.Date import javax.persistence._ import scala.beans.BeanProperty import collection.JavaConversions._ @Entity @Table(name = "news") class News (p_title : String, p_appName : String, p_appVersion : String, p_userCreated : String, p_downloadLink : String, p_imageLi...
Explain and rewrite the following Scala code:
package net.sansa_stack.rdf.spark.ops import com.holdenkarau.spark.testing.DataFrameSuiteBase import org.apache.jena.graph.{Node, NodeFactory, Triple} import org.apache.jena.query.{QueryFactory, Syntax} import org.apache.jena.rdf.model.{Model, ModelFactory} import org.apache.jena.vocabulary.RDF import org.apache.spark...
Explain and rewrite the following Scala code:
import scala.reflect.runtime.universe._ import scala.reflect.runtime.universe.definitions._ import scala.reflect.runtime.{currentMirror => cm} package scala { object ExceptionUtils { def unwrapThrowable(ex: Throwable): Throwable = scala.reflect.runtime.ReflectionUtils.unwrapThrowable(ex) } } object Test exten...
Explain and rewrite the following Scala code:
package net.yantene.poifullchan import twitter4j._ object Poifullchan { def main(args: Array[String]) { val twitterStream = new TwitterStreamFactory().getInstance twitterStream.addListener(new PoifullStream) twitterStream.user } }
Explain and rewrite the following Scala code:
package com.tajpure.scheme.compiler.value.premitives import com.tajpure.scheme.compiler.value.PrimFunc import com.tajpure.scheme.compiler.value.Value import com.tajpure.scheme.compiler.ast.Node import com.tajpure.scheme.compiler.value.BoolValue import com.tajpure.scheme.compiler.util.Log import com.tajpure.scheme.comp...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2015-2016 Luciano Resende * * 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 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 to in writing, software distr...
Explain and rewrite the following Scala code:
import scala.quoted.* object Macros { inline def m[R](sym: Symantics[R]) : R = ${ mImpl[R]('{sym}) } def mImpl[R: Type](using Quotes)(sym: Expr[Symantics[R]]): Expr[R] = '{ $sym.Meth(42) } } trait Symantics[R] { def Meth(exp: Int): R }
Explain and rewrite the following Scala code:
package com.twitter.finatra.tests.json.internal.caseclass.validation.validators import com.twitter.finatra.json.internal.caseclass.validation.validators.MaxValidator import com.twitter.finatra.validation.ValidationResult.{invalid, valid} import com.twitter.finatra.validation.{Max, ValidationResult, ValidatorTest} cas...
Explain and rewrite the following Scala code:
import scala.scalajs.js import scala.scalajs.js.annotation.* import scala.scalajs.js.Dynamic.literal object Test { def test(): Unit = { literal.helloWorld(a = "a") // error literal.helloWorld("a" -> "a") // error val x = "string" literal.applyDynamicNamed(x)() // error literal.applyDynamic(x)() ...
Explain and rewrite the following Scala code:
package net.andimiller.iql import fastparse.core.Parsed.{Failure, Success} import org.scalatest.{FlatSpec, MustMatchers} import cats._ import cats.data.NonEmptyList import cats.implicits._ import cats.syntax._ import fastparse.all._ /** * Created by andi on 23/12/2015. */ class ParserSpec extends FlatSpec with Mu...
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 edu.gemini.model.p1.immutable import edu.gemini.model.p1.{mutable => M} import GuidingEvaluation._ object GuidingEstimation { def apply(m: M.GuidingEstimation): GuidingEstimation = m.getPercentage match { case x if x >= 0 && x <= 100 => GuidingEstimation(x) case _ => GuidingEst...
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.ponkotuy.restype import com.ponkotuy.data.master.MasterRemodel import com.ponkotuy.parser.Query import org.json4s.native.Serialization.write import scala.util.matching.Regex /** * @author ponkotuy * Date: 15/04/12. */ case object RemodelSlotlistDetail extends ResType { import ResType._ override d...
Explain and rewrite the following Scala code:
package sjs.react.bootstrap import japgolly.scalajs.react._ import japgolly.scalajs.react.vdom.prefix_<^._ import scala.scalajs.js object PageHeader /* mixins: */ { val component = ReactComponentB[Props]("PageHeader") .render((P, C) => { <.div(^.cls := P.className, ^.cls := "page-header", <.h1(C)) } ...
Explain and rewrite the following Scala code:
package se.gigurra.wallace.renderer import java.io.Closeable trait RenderAsset[+SourceType] extends Closeable { def dispose(): Unit = {} def upload(): Unit = {} def width: Float def height: Float def draw[AssetsType]()(implicit renderContext: RenderContext[AssetsType]): Unit override def close(): Unit = ...
Explain and rewrite the following Scala code:
package io.iohk.ethereum.db.dataSource import java.util.concurrent.locks.ReentrantReadWriteLock import io.iohk.ethereum.utils.Logger import cats.effect.Resource import io.iohk.ethereum.db.dataSource.DataSource._ import io.iohk.ethereum.db.dataSource.RocksDbDataSource._ import io.iohk.ethereum.utils.TryWithResources.wi...
Explain and rewrite the following Scala code:
package org.deeplearning4j.spark.ml.utils import org.apache.hadoop.fs.Path import org.apache.spark.SparkContext import org.apache.spark.ml.param.{ParamPair, Params} import org.apache.spark.ml.util.{MLReadable, MLReader} import org.apache.spark.sql.types.{DataType, StructField, StructType} import org.deeplearning4j.spa...
Explain and rewrite the following Scala code:
/* * Copyright 2013 Katarzyna Szawan <kat.szwn@gmail.com> * and Michał Rus <https://michalrus.com/> * * 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/l...
Explain and rewrite the following Scala code:
package controllers import play.api.mvc._ import scala.concurrent.Future import play.api.mvc.Results._ class UserRequest[A](val email: Option[String], request: Request[A]) extends WrappedRequest[A](request) class AuthenticatedRequest[A](val email: String, request: Request[A]) extends WrappedRequest[A](request) obje...
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:
object DivergingImplicits { type C type D object Circular { implicit def f( implicit c: C ): D = ??? implicit def g( implicit d: D ): C = ??? implicitly[C] } }
Explain and rewrite the following Scala code:
package edu.holycross.shot.ohco2 import org.scalatest.FlatSpec import edu.holycross.shot.cite._ /** */ class CatalogLabellingSpec extends FlatSpec { val catalogData = """urn#citationScheme#groupName#workTitle#versionLabel#exemplarLabel#online#lang urn:cts:greekLit:tlg5026.msA.hmt:#book/scholion/part#Scholia to the...
Explain and rewrite the following Scala code:
package carldata.sf.compiler import carldata.sf.compiler.AST.Module import carldata.sf.compiler.Executable.ExecCode /** * Generate executable code from AST */ object CodeGenerator { def generate(ast: Module): ExecCode = { ExecCode(ast.funDecl) } }
Explain and rewrite the following Scala code:
package com.whitepages.kafka.concurrent.messagesource import java.util.Properties import com.whitepages.kafka.concurrent.BatchAckingMessageSource import kafka.consumer.{ConsumerTimeoutException, ConsumerConfig} import kafka.message.MessageAndMetadata import kafka.serializer.{DefaultDecoder, StringDecoder, Decoder} i...