673 questions
Tooling
0
votes
1
replies
106
views
How to make an AI model come alive?
For fun, I developed an AI model with short-term, medium-term, and long-term memory, inspired by neuro-sama. (I'm a regular backend developer, I don't know much about AI).
How it works:
mic -> vad -...
0
votes
1
answer
53
views
CML using SML-NJ --- Error: unbound structure: Test in path Test.main
I sucessfully compiled SML using the instructions from here and I try to execute this CML hello world program:
% cat cml_test.cm
Library
structure Hello
is
$cml/basis.cm
$cml/cml.cm
...
0
votes
1
answer
73
views
In ML How do you keep the delimiter in the output of the String.tokens function?
Here is a basic implementation of the tokens function:
fun f c = c = #" ";
val testStr = "int main(){return 42;}";
val stringL = String.tokens f testStr;
It returns:
val stringL = ...
0
votes
0
answers
105
views
Please answer this in SOSML
In SOSML Write the following ML functions using, whenever possible, pattern-matching function definitions.
Function union of type 'a list * 'a list → 'a list that returns the union of two lists (in ...
1
vote
1
answer
90
views
Multiplying real number extracted of a pair using case of in StandarML
I create a datatype and a function. The function must be able to do a multiplication according to whether the members of the pair are int(s) or real(s). I can get to work for Int, but when I add a ...
2
votes
2
answers
299
views
Evaluation order of let-in expressions with tuples
My old notes on ML say that
let (𝑣₁, … , 𝑣ₙ) = (𝑡₁, … , 𝑡ₙ) in 𝑡′
is a syntactic sugar for
(λ 𝑣ₙ. … (λ 𝑣₁. 𝑡′)𝑡₁ … )𝑡ₙ
and that
let (𝑣₁, 𝑣₂) = 𝑡 𝑡′ in 𝑡″
is equivalent to
let 𝑣 = 𝑡 ...
1
vote
1
answer
64
views
SML returns the same tuples
I'm currently learning Standard ML, just for fun; What I'm trying to do is generate a list of 3-tuples of random ints between 1 and 100. My code:
fun reload() = use "filtertest.sml";
fun ...
0
votes
2
answers
88
views
Symmetric Relation Recursive SML
Define a recursive predicate in ML isRelationSymmetric that accepts a relation r (represented as a list of tuples) and returns true if r is symmetric and false otherwise.
Here is what I have so far.
...
-1
votes
1
answer
246
views
Recusive ML function of exponential with three variable helper function
I need help figuring out what I need to do for the helper function recursively, I am kinda lost of in what I need to do for the helper function.
Here is the question and the example input.
Here is ...
0
votes
2
answers
75
views
How do you see if adjacent elements repeat in a list? (SML)
SML is a challenging language for me to learn. I'm trying to find a way to screen an undetermined list and return a boolean based on whether two elements adjacent on a list are the same value or not. ...
0
votes
1
answer
275
views
How do you sort a list from least to greatest in Standard ML?
I'm new to ML, and a bit of my code isn't working. I'm creating a function in ML where it's supposed to sort reals and then compile them into a single list. I created a large if-then statement, but it ...
1
vote
1
answer
274
views
How can I use functions written in ML inside Isabelle?
Apologies if this is considered a dumb question, but how can I make an Isabelle theory recognise ML code? For example, let's say I have an Isabelle file that looks like
ML ‹
type vec = real * real;
...
5
votes
0
answers
141
views
HMF inference for recursive functions
I'm working on an implementation of the HMF type system described in this paper by Daan Leijen.
The inference algorithm for HMF is defined in section 6.3. Here is the rule for let expressions (...
1
vote
1
answer
205
views
How do you convert a character to a real in SML?
If I'm trying to do this:
Convert #”N” to a real
What ML expression would do this?
In the same way that:\
str = Char -> string
chr = int -> Char
ord = Char -> int
real = int -> real
Is ...
2
votes
2
answers
2k
views
OCaml physical and structural equality
I understading than x == y is false because each is instantiated in different memory locations (https://stackoverflow.com/a/1412688/11439260). But i expected than a == b is false. Why this is true? ...
3
votes
1
answer
359
views
SML: Exception while reading a line of integers
fun parse file =
let
(* A function to read an integer from specified input. *)
fun readInt input =
Option.valOf (TextIO.scanStream (Int.scan StringCvt.DEC) input)
in
...
0
votes
1
answer
71
views
Recursion In simple ML Standard
fun max (xs : int list)=
if null xs
then NONE
else
let val tl_ans = max(tl xs)
in
if isSome tl_ans andalso valOf tl_ans > hd xs
then
tl_ans
else
...
2
votes
1
answer
221
views
`(a,b)` versus `(a*b)` in ocaml
It seems that only a * b can fit in to _ and only (a,b) can fit in to (a,_).
I can imagine that a*b is a proper type for the internal product with components a and b whereas (a,b) is a external ...
2
votes
2
answers
204
views
I got some trouble with ocaml polymorphic function
i need your help please, where is the error in my code ?
let create = Array.make_matrix 10 10;;
let assoc int = create int,create (char_of_int int);;
the error is
3 | let assoc int = create int,...
0
votes
1
answer
73
views
Deleting middle element out of a given list in ML
I am brand new to learning standard ML. I want to make a function that takes a list/lists of 3 numbers and deletes the middle number and then reverse the order of the two numbers. So if I have a ...
0
votes
1
answer
885
views
how to print in ML
I've searched and found several people asking this question, but I can't find an explicit answer.
How can I print a non-string in sml?
For example if I have an instance of an ADT, i.e., of a type ...
0
votes
1
answer
188
views
How to pattern match an ADT in ML
I'm brand new to ML and I'm trying to figure out the syntax for pattern matching.
Can someone help me understand the compiler error, and the correct syntax for pattern matching an AssignStm while ...
2
votes
1
answer
170
views
How to get ML values from HOL?
I have an embedded ML code like this:
ML ‹
val boo = true;
val num = 1234;
val rea = 3.14;
val str = "hi";
›
Can anyone give me an example of code that gets those values from HOL?
0
votes
1
answer
530
views
Ocaml function parsing list of lists
I am trying to build a function in Ocaml which parses a list of lists, eg from [[0;1];[3;4;8]] to [0;1;3;4;8]. I tried to do something like:
#let rec parse listoflists=
match listoflists with
[[]...
11
votes
1
answer
2k
views
Examples of the difference between `prompt/control` and `shift/reset`
I am not sure I understand the difference between the delimited continuation operator pairs prompt/control and reset/shift. I understand some basic examples of use, but in those examples their ...