我对Kotlin来说是全新的,我正在尝试运行Kotlin REPL。
关注this,考虑到我使用的是OS X,我试过这个:
$ /usr/local/bin/kotlinc-jvm
相当于:
$ kotlinc-jvm
然后在the following link中,我发现运行它的更好方法是:
$ kotlinc
这两个命令之间有什么区别,我应该选择哪一个?
答案 0 :(得分:3)
如果您查看kotlinc-jvm
文件,他们实际上只是启动它们所在的同一文件夹中的#!/usr/bin/env bash
# (License here)
DIR="${BASH_SOURCE[0]%/*}"
: ${DIR:="."}
"${DIR}"/kotlinc "$@"
,并将它们所启动的任何参数传递给它:
kotlinc-jvm.bat
:
@echo off
rem (License here)
call %~dps0kotlinc.bat %*
适用于Windows的 kotlinc-jvm
:
kotlinc
我不确定为什么using System;
using System.Collections.Generic;
namespace ProbabilityDistribution1
{
class Program
{
// This derived class converts the uniformly distributed random
// numbers generated by base.Sample( ) to another distribution.
class RandomProportional : Random
{
// The Sample method generates a distribution more concentrated around the 0, in the range [0.0, 1.0].
protected override double Sample()
{
double BSample = base.Sample();
const double concentrationAroundInputs = 5;//more concentrated when greater
double result = Math.Pow(BSample, concentrationAroundInputs);
return result;
}
}
static double XCoordinateOfRandomUnitInsideSphere(Random aRandom)
{
//Even with uniform distribution the probability of exiting is greater than 0.5 on each iteration
while (true)
{
double x = aRandom.NextDouble();
double y = aRandom.NextDouble();
double z = aRandom.NextDouble();
if ((x * x + y * y + z * z) < 1) //inside the sphere
{
return x;
}
}
}
static void TestDistribution()
{
double[] Input = { 1, 16, 19, 21 };
List<int> sampleValues = new List<int>();
Random aRandom = new Random();
RandomProportional aRandomProportinal = new RandomProportional();
for (int i = 0; i < 100; i++)
{
int value = 0;
do
{
int indexChosen = aRandom.Next(4);
double xCoordinate = XCoordinateOfRandomUnitInsideSphere(aRandomProportinal);
if (aRandom.Next(2)==0)
{
xCoordinate = -xCoordinate;
}
double xRandomResult = xCoordinate * 64;
value = (int)(Input[indexChosen] + xRandomResult);
} while (value < 1 || value > 64);
sampleValues.Add((int)value);
}
sampleValues.Sort();
Console.WriteLine();
foreach (int i in sampleValues)
{
Console.Write(" {0:00} ", i);
}
Console.WriteLine();
}
static void Main(string[] args)
{
TestDistribution();
Console.WriteLine("end");
Console.ReadLine();
}
}
}
在这种形式中存在,它基本上只是一个非常简单的重定向。我只使用if(rs.next()){
。