Sha256: 5a29fd6f6bb8050402b389dd71761768c6bf9d2c40d8cdd6d587233eac8c12f2

Contents?: true

Size: 924 Bytes

Versions: 5

Compression:

Stored size: 924 Bytes

Contents

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL logical `rand` operator.
    #
    # Returns a pseudo-random number between 0 (inclusive) and 1.0e0 (exclusive). Different numbers can be produced every time this function is invoked. Numbers should be produced with approximately equal probability.
    #
    # @example
    #   (rand)
    #
    # @see https://www.w3.org/TR/sparql11-query/#idp2130040
    class Rand < Operator::Nullary
      include Evaluatable

      NAME = :rand

      ##
      # Returns a pseudo-random number between 0 (inclusive) and 1.0e0 (exclusive). Different numbers can be produced every time this function is invoked. Numbers should be produced with approximately equal probability.
      #
      # @return [RDF::Literal::Double] random value
      def apply
        RDF::Literal::Double.new(Random.rand)
      end
    end # Rand
  end # Operator
end; end # SPARQL::Algebra

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sparql-3.1.6 lib/sparql/algebra/operator/rand.rb
sparql-3.1.5 lib/sparql/algebra/operator/rand.rb
sparql-3.1.4 lib/sparql/algebra/operator/rand.rb
sparql-3.1.3 lib/sparql/algebra/operator/rand.rb
sparql-3.1.2 lib/sparql/algebra/operator/rand.rb