Posts

Conditional Statement in SML (if else in SML)

Image
Conditional Statement in SML (if-else in SML) Like any other programming language, SML also has a conditional statement. Syntax of a conditional statement is: - if "Condition to be Check" then "True Condition " else "False Condition" ; e.g. - val a=10; - val b=20; - if a>b then print("a is greater") else print("b is greater"); Greatest among two screenshots.

Looping in SML

Image
Looping in SML  To learn how to install sml and open the SML console visit  https://aamir0509.blogspot.com/2019/09/introduction-to-sml-standard-meta.html In an earlier post, we have learned about the basic concepts of, as there is no predefined syntax for the looping, but we can create it by using the recursive function. following is the sample code snippet for printing number from 1 to 10.  (*Loop printing program in SML-NJ *) (* To under stand the looping concept in SML-NJ*) (* In function loop 2 values are passed 1. Initialization 2. Termination *) fun loop (n,max) =   if n > max then     print "\n"   else (     print (Int.toString (n)^"\n");     loop (n + 1,max)   ); loop (1,10);(*loop(initilization , termination)*) For Table printing in SML visit the link.  https://aamir0509.blogspot.com/2019/09/print-table-in-sml-nj.html

Print table in SML-NJ

Image
Print Table in SML  Following is the code snippet for printing table in sml. (*Table printing program in SML-NJ *) (* To under stand the looping concept in SML-NJ*) (* In function table 3 values are passed 1. Start 2. Number table to be printed 3. Maximum (Upto where table to be printed) *) fun table (n,num,max) =   if n > max then     print "\n"   else (     print (Int.toString (num) ^ " * " ^Int.toString (n) ^" = "^Int.toString (n*num) ^"\n");     table (n + 1,num,max)   ); table (1,2,10);(*table(initilization , table to be printed , Upto the limit)*) Output: Screenshot of Table Printing code (Above Code)

Arithmetic Operations in SML/NJ

Image
Arithmetic Operations in SML/NJ To learn  Getting Started with SML visit https://aamir0509.blogspot.com/2019/09/getting-started-with-sml.html In SML arithmetic operations work on similar datatypes of elements for e.g. int is added with int, real is added with real (Hear float number is real) Addition (+) operation: ( work for both int and real.) e.g.  val real_addition =10.5 + 4.0;  (Result: val real_addition = 14.5 : real ) val int_ addition   = 10 + 4;    ( Result:  val int_addition = 14 : int ) Subtraction (-) operation: ( work for both int and real.) e.g.  val real_sub =10.5 - 4.0;  (Result:  val real_sub = 6.5 : real ) val int_sub   = 10 - 4;    ( Result:  val int_sub = 6 : int ) Multiplication (+) operation: ( work for both int and real.) e.g.  val real_mul =10.5 + 4.0;  (Result:  val real_mul = 42.0 : real) val int_mul   = 10 * 4;...

Getting Started with SML

Image
Getting Started with SML  To learn how to install sml and open the SML console visit  https://aamir0509.blogspot.com/2019/09/introduction-to-sml-standard-meta.html In the previous post, we have learned about how to install and open the SML console. Lets now get started with the first program to print "Hello World". Open SML console and write - print("Hello World");  and press   Enter . Comments in SML Comments in Standard ML begin with (* and end with *) Variable Declarations in SML SML will automatically find the variable datatype we did not need to explicitly  declare types.  val a = 10;                    (val a = 5551337 : int) val a = 5551337;          (val a = 5551337 : int) val a = 3.14159;           (val a = 3.14159 : real) val a = ~10;                  (va...

Introduction to SML (Standard Meta Language)

Image
Introduction to SML (Standard Meta Language) Meta Language was firstly introduced in the 1970’s and was invented in University of Edinburgh's LCF project, led by Robin Milner et al. It was developed for theorem proving and escribing and implementing proof strategies. There are two implementation modules Objective Caml and Standard ML. In the year 1997, ML97 revision of Standard ML was introduced. Steps to Download and install SML/NJ on windows. Step 1. Download SML/NJ using  http://smlnj.cs.uchicago.edu/dist/working/110.91/smlnj-110.91.msi Step 2. Double click on the setup and click next and install. After installation search, CMD in the start menu or  W  +    R   and press   Enter . It will open the command window or console screen. Step 3. Once command screen opens write sml and press enter. Now you can code in SML. Step 4.  To exit from SLM console press  W  +    Z   and pre...
Code for Cloud end-point project MyBena Class file code package com.example.myendpoint; public class MyBean { private String msg; public String getMessage() { return msg; } public void setMessage(String str) { msg=str; } } YourFirstAPI Java file package com.example.myendpoint; import com.google.api.server.spi.config.Api; import com.google.api.server.spi.config.ApiMethod; import com.google.api.server.spi.config.ApiNamespace; import javax.inject.Named; @Api(name = "skeleton-api",      version = "v1",      namespace=@ApiNamespace(ownerDomain="greeting.example.com",ownerName="greeting.example.com",packagePath="")) public class YourFirstAPI { @ApiMethod(name="hiThere") public MyBean hiThere(@Named("name") String name) { MyBean response=new MyBean(); response.setMessage("Hi, "+name); return response; } }