C#代码变成了clojure代码 [英] C# code into clojure code

查看:94
本文介绍了C#代码变成了clojure代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everyone,



我是Clojure的新手,我很难找到代码示例作为参考。

我的assigment因为我的班级要求我构建一个我们可以输入权力(数字和指数)的代码。我构建的C#代码是这样的:



Hello Everyone,

I am new at Clojure and I am having a difficult time finding code examples as reference.
My assigment for my class is asking me to construct a code where we could enter powers (numbers and exponents). My C# code I constructed was this one:

using System;

class AI_Assignment_1

{
   static string PowerProblemString(double x, double y)
   {
      double sum = Math.Pow (x, y);
      string sentence = x + " To The " + y + " Power Of Equals to " + sum;
      return sentence; 
   }
   static void Main()
   {
      Console.Write("Enter Your Base Number: ");
      double a = double.Parse(Console.ReadLine());
      Console.Write("Enter Your Exponent Number: ");
      double b = double.Parse(Console.ReadLine());
      Console.WriteLine(PowerProblemString(a, b));
   }
}

And here is my powers code I'm using for Clojure

(defn exp [x n]
     (if (zero? n) 1
         (* x (exp x (dec n)))))





我尝试过:



我只想在Clojure中运行相同的程序,你可以输入你的数字和指数。



What I have tried:

I'd simply would like to run the same program in Clojure where you could enter your number and exponent.

推荐答案

请参见 Clojure [ ^ ]。


这篇关于C#代码变成了clojure代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆