String from a char

I know how to make a string from a given char , but I need to know how to
do it in ATS without using C snippets.

Say I have function make_string that takes a char and return a string :

fun make_string (c : char) : string

This function return empty string when c = 0

Example : make_string (‘a’) => "a"
make_string (’\0’) => “”

In particular I want to make use of “string_sing” inside the function.

I am unable to compile the above function even when I take ‘\0’ into
account.

Thanks

Great , thanks for fixing it , I’ll update my copy soon.On Wed, Jul 2, 2014 at 8:34 PM, gmhwxi gmh...@gmail.com wrote:

I noted that string_sing was not implemented. I just fixed it.

implement
{}(tmp)
string_sing (c) = let
val (pfat, pfgc | p) = malloc_gc (i2sz(2))
val ((void)) = $UN.ptr0_set (p, c)
val ((void)) = $UN.ptr0_set_at (p, 1, ‘\000’)
in
$UN.castvwtp0{strnptr(1)}((pfat, pfgc | p))
end // end of [string_sing]

On Wednesday, July 2, 2014 10:44:32 AM UTC-4, gmhwxi wrote:

Did you have the following line at the top:

#include “share/atspre_staload.hats”

On Wednesday, July 2, 2014 10:38:52 AM UTC-4, Chotu S wrote:

Now the code passes the type checker , but unfortunately I am still
getting compiler errors.

implement main0 () = {
val c = ‘\0’
val s = make_string (c)
}

this does not compile and give me an error (I used to get this kind of
error a lot , but have forgotten how I fixed it before , may be something
to do with size or template )

Thanks

On Wed, Jul 2, 2014 at 6:47 PM, gmhwxi gmh...@gmail.com wrote:

string_sing can only be applied to a non-zero char:

fun make_string (c: char) = let
val c = g1ofg0 (c)
in
if iseqz (c) then “” else strnptr2string(string_sing(c))
end

On Wednesday, July 2, 2014 9:11:25 AM UTC-4, Chotu S wrote:

I meant something like this :

fun make_string (c : char) : string =
if c = ‘\0’ then “”
else strnptr2string (string_sing (c))

On Wed, Jul 2, 2014 at 6:28 PM, Brandon Barker brand...@gmail.com wrote:

Could you include your code? I’m not sure what is meant by your
last statement about ‘\0’.

Brandon Barker
brand...@gmail.com

On Wed, Jul 2, 2014 at 8:54 AM, Chotu S cho...@gmail.com wrote:

I know how to make a string from a given char , but I need to know
how to do it in ATS without using C snippets.

Say I have function make_string that takes a char and return a
string :

fun make_string (c : char) : string

This function return empty string when c = 0

Example : make_string (‘a’) => “a”
make_string (‘\0’) => “”

In particular I want to make use of “string_sing” inside the
function.

I am unable to compile the above function even when I take ‘\0’ into
account.

Thanks


You received this message because you are subscribed to the Google
Groups “ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it,
send an email to ats-lang...@googlegroups.com.
To post to this group, send email to ats-l...@googlegroups.com.

Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4yOBa
Eb6ZJze6NK-_So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4yOBaEb6ZJze6NK-_So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com?utm_medium=email&utm_source=footer
.


You received this message because you are subscribed to the Google
Groups “ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it,
send an email to ats-lang...@googlegroups.com.
To post to this group, send email to ats-l...@googlegroups.com.

Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/
msgid/ats-lang-users/CAORbNRqPyNPFLxx5LbQQwGnNUgHscqQiTnU4-
A6y_2gd536EkA%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAORbNRqPyNPFLxx5LbQQwGnNUgHscqQiTnU4-A6y_2gd536EkA%40mail.gmail.com?utm_medium=email&utm_source=footer
.


You received this message because you are subscribed to the Google
Groups “ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to ats-lang...@googlegroups.com.
To post to this group, send email to ats-l...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/
msgid/ats-lang-users/adc353f4-c4a1-4727-ba88-1c0dccb634f4%
40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/adc353f4-c4a1-4727-ba88-1c0dccb634f4%40googlegroups.com?utm_medium=email&utm_source=footer
.


You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/d3b53554-07e6-44fb-8a50-492b469312dc%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/d3b53554-07e6-44fb-8a50-492b469312dc%40googlegroups.com?utm_medium=email&utm_source=footer
.

Could you include your code? I’m not sure what is meant by your last
statement about ‘\0’.

Brandon Barker
brandon…@gmail.comOn Wed, Jul 2, 2014 at 8:54 AM, Chotu S chot...@gmail.com wrote:

I know how to make a string from a given char , but I need to know how to
do it in ATS without using C snippets.

Say I have function make_string that takes a char and return a string :

fun make_string (c : char) : string

This function return empty string when c = 0

Example : make_string (‘a’) => “a”
make_string (‘\0’) => “”

In particular I want to make use of “string_sing” inside the function.

I am unable to compile the above function even when I take ‘\0’ into
account.

Thanks


You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4yOBaEb6ZJze6NK-_So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4yOBaEb6ZJze6NK-_So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com?utm_medium=email&utm_source=footer
.

So main problem was forgetting to convert type to dependent type i.e char
to char (c) .On Wed, Jul 2, 2014 at 6:47 PM, gmhwxi gmh...@gmail.com wrote:

string_sing can only be applied to a non-zero char:

fun make_string (c: char) = let
val c = g1ofg0 (c)
in
if iseqz (c) then “” else strnptr2string(string_sing(c))
end

On Wednesday, July 2, 2014 9:11:25 AM UTC-4, Chotu S wrote:

I meant something like this :

fun make_string (c : char) : string =
if c = ‘\0’ then “”
else strnptr2string (string_sing (c))

On Wed, Jul 2, 2014 at 6:28 PM, Brandon Barker brand...@gmail.com wrote:

Could you include your code? I’m not sure what is meant by your last
statement about ‘\0’.

Brandon Barker
brand...@gmail.com

On Wed, Jul 2, 2014 at 8:54 AM, Chotu S cho...@gmail.com wrote:

I know how to make a string from a given char , but I need to know how
to do it in ATS without using C snippets.

Say I have function make_string that takes a char and return a string :

fun make_string (c : char) : string

This function return empty string when c = 0

Example : make_string (‘a’) => “a”
make_string (‘\0’) => “”

In particular I want to make use of “string_sing” inside the function.

I am unable to compile the above function even when I take ‘\0’ into
account.

Thanks


You received this message because you are subscribed to the Google
Groups “ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to ats-lang...@googlegroups.com.
To post to this group, send email to ats-l...@googlegroups.com.

Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/
msgid/ats-lang-users/CAAZxu4yOBaEb6ZJze6NK-_
So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4yOBaEb6ZJze6NK-_So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com?utm_medium=email&utm_source=footer
.


You received this message because you are subscribed to the Google
Groups “ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to ats-lang...@googlegroups.com.
To post to this group, send email to ats-l...@googlegroups.com.

Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/
msgid/ats-lang-users/CAORbNRqPyNPFLxx5LbQQwGnNUgHsc
qQiTnU4-A6y_2gd536EkA%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAORbNRqPyNPFLxx5LbQQwGnNUgHscqQiTnU4-A6y_2gd536EkA%40mail.gmail.com?utm_medium=email&utm_source=footer
.


You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/adc353f4-c4a1-4727-ba88-1c0dccb634f4%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/adc353f4-c4a1-4727-ba88-1c0dccb634f4%40googlegroups.com?utm_medium=email&utm_source=footer
.

I noted that string_sing was not implemented. I just fixed it.

implement
{}(tmp)
string_sing (c) = let
val (pfat, pfgc | p) = malloc_gc (i2sz(2))
val ((void)) = $UN.ptr0_set (p, c)
val ((void)) = $UN.ptr0_set_at (p, 1, ‘\000’)
in
$UN.castvwtp0{strnptr(1)}((pfat, pfgc | p))
end // end of [string_sing]On Wednesday, July 2, 2014 10:44:32 AM UTC-4, gmhwxi wrote:

Did you have the following line at the top:

#include “share/atspre_staload.hats”

On Wednesday, July 2, 2014 10:38:52 AM UTC-4, Chotu S wrote:

Now the code passes the type checker , but unfortunately I am still
getting compiler errors.

implement main0 () = {
val c = ‘\0’
val s = make_string (c)
}

this does not compile and give me an error (I used to get this kind of
error a lot , but have forgotten how I fixed it before , may be something
to do with size or template )

Thanks

On Wed, Jul 2, 2014 at 6:47 PM, gmhwxi gmh...@gmail.com wrote:

string_sing can only be applied to a non-zero char:

fun make_string (c: char) = let
val c = g1ofg0 (c)
in
if iseqz (c) then “” else strnptr2string(string_sing(c))
end

On Wednesday, July 2, 2014 9:11:25 AM UTC-4, Chotu S wrote:

I meant something like this :

fun make_string (c : char) : string =
if c = ‘\0’ then “”
else strnptr2string (string_sing (c))

On Wed, Jul 2, 2014 at 6:28 PM, Brandon Barker brand...@gmail.com wrote:

Could you include your code? I’m not sure what is meant by your last
statement about ‘\0’.

Brandon Barker
brand...@gmail.com

On Wed, Jul 2, 2014 at 8:54 AM, Chotu S cho...@gmail.com wrote:

I know how to make a string from a given char , but I need to know
how to do it in ATS without using C snippets.

Say I have function make_string that takes a char and return a string
:

fun make_string (c : char) : string

This function return empty string when c = 0

Example : make_string (‘a’) => “a”
make_string (‘\0’) => “”

In particular I want to make use of “string_sing” inside the
function.

I am unable to compile the above function even when I take ‘\0’ into
account.

Thanks


You received this message because you are subscribed to the Google
Groups “ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it,
send an email to ats-lang...@googlegroups.com.
To post to this group, send email to ats-l...@googlegroups.com.

Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/
msgid/ats-lang-users/CAAZxu4yOBaEb6ZJze6NK-_
So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4yOBaEb6ZJze6NK-_So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com?utm_medium=email&utm_source=footer
.


You received this message because you are subscribed to the Google
Groups “ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to ats-lang...@googlegroups.com.
To post to this group, send email to ats-l...@googlegroups.com.

Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/
msgid/ats-lang-users/CAORbNRqPyNPFLxx5LbQQwGnNUgHsc
qQiTnU4-A6y_2gd536EkA%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAORbNRqPyNPFLxx5LbQQwGnNUgHscqQiTnU4-A6y_2gd536EkA%40mail.gmail.com?utm_medium=email&utm_source=footer
.


You received this message because you are subscribed to the Google
Groups “ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to ats-lang...@googlegroups.com.
To post to this group, send email to ats-l...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/adc353f4-c4a1-4727-ba88-1c0dccb634f4%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/adc353f4-c4a1-4727-ba88-1c0dccb634f4%40googlegroups.com?utm_medium=email&utm_source=footer
.

I meant something like this :

fun make_string (c : char) : string =
if c = ‘\0’ then “”
else strnptr2string (string_sing (c))On Wed, Jul 2, 2014 at 6:28 PM, Brandon Barker brandon...@gmail.com wrote:

Could you include your code? I’m not sure what is meant by your last
statement about ‘\0’.

Brandon Barker
brandon...@gmail.com

On Wed, Jul 2, 2014 at 8:54 AM, Chotu S chot...@gmail.com wrote:

I know how to make a string from a given char , but I need to know how to
do it in ATS without using C snippets.

Say I have function make_string that takes a char and return a string :

fun make_string (c : char) : string

This function return empty string when c = 0

Example : make_string (‘a’) => “a”
make_string (‘\0’) => “”

In particular I want to make use of “string_sing” inside the function.

I am unable to compile the above function even when I take ‘\0’ into
account.

Thanks


You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4yOBaEb6ZJze6NK-_So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4yOBaEb6ZJze6NK-_So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com?utm_medium=email&utm_source=footer
.


You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAORbNRqPyNPFLxx5LbQQwGnNUgHscqQiTnU4-A6y_2gd536EkA%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAORbNRqPyNPFLxx5LbQQwGnNUgHscqQiTnU4-A6y_2gd536EkA%40mail.gmail.com?utm_medium=email&utm_source=footer
.

Now the code passes the type checker , but unfortunately I am still getting
compiler errors.

implement main0 () = {
val c = ‘\0’
val s = make_string (c)
}

this does not compile and give me an error (I used to get this kind of
error a lot , but have forgotten how I fixed it before , may be something
to do with size or template )

ThanksOn Wed, Jul 2, 2014 at 6:47 PM, gmhwxi gmh...@gmail.com wrote:

string_sing can only be applied to a non-zero char:

fun make_string (c: char) = let
val c = g1ofg0 (c)
in
if iseqz (c) then “” else strnptr2string(string_sing(c))
end

On Wednesday, July 2, 2014 9:11:25 AM UTC-4, Chotu S wrote:

I meant something like this :

fun make_string (c : char) : string =
if c = ‘\0’ then “”
else strnptr2string (string_sing (c))

On Wed, Jul 2, 2014 at 6:28 PM, Brandon Barker brand...@gmail.com wrote:

Could you include your code? I’m not sure what is meant by your last
statement about ‘\0’.

Brandon Barker
brand...@gmail.com

On Wed, Jul 2, 2014 at 8:54 AM, Chotu S cho...@gmail.com wrote:

I know how to make a string from a given char , but I need to know how
to do it in ATS without using C snippets.

Say I have function make_string that takes a char and return a string :

fun make_string (c : char) : string

This function return empty string when c = 0

Example : make_string (‘a’) => “a”
make_string (‘\0’) => “”

In particular I want to make use of “string_sing” inside the function.

I am unable to compile the above function even when I take ‘\0’ into
account.

Thanks


You received this message because you are subscribed to the Google
Groups “ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to ats-lang...@googlegroups.com.
To post to this group, send email to ats-l...@googlegroups.com.

Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/
msgid/ats-lang-users/CAAZxu4yOBaEb6ZJze6NK-_
So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4yOBaEb6ZJze6NK-_So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com?utm_medium=email&utm_source=footer
.


You received this message because you are subscribed to the Google
Groups “ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to ats-lang...@googlegroups.com.
To post to this group, send email to ats-l...@googlegroups.com.

Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/
msgid/ats-lang-users/CAORbNRqPyNPFLxx5LbQQwGnNUgHsc
qQiTnU4-A6y_2gd536EkA%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAORbNRqPyNPFLxx5LbQQwGnNUgHscqQiTnU4-A6y_2gd536EkA%40mail.gmail.com?utm_medium=email&utm_source=footer
.


You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/adc353f4-c4a1-4727-ba88-1c0dccb634f4%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/adc353f4-c4a1-4727-ba88-1c0dccb634f4%40googlegroups.com?utm_medium=email&utm_source=footer
.

Did you have the following line at the top:

#include "share/atspre_staload.hats"On Wednesday, July 2, 2014 10:38:52 AM UTC-4, Chotu S wrote:

Now the code passes the type checker , but unfortunately I am still
getting compiler errors.

implement main0 () = {
val c = ‘\0’
val s = make_string (c)
}

this does not compile and give me an error (I used to get this kind of
error a lot , but have forgotten how I fixed it before , may be something
to do with size or template )

Thanks

On Wed, Jul 2, 2014 at 6:47 PM, gmhwxi <gmh...@gmail.com <javascript:>> wrote:

string_sing can only be applied to a non-zero char:

fun make_string (c: char) = let
val c = g1ofg0 (c)
in
if iseqz (c) then “” else strnptr2string(string_sing(c))
end

On Wednesday, July 2, 2014 9:11:25 AM UTC-4, Chotu S wrote:

I meant something like this :

fun make_string (c : char) : string =
if c = ‘\0’ then “”
else strnptr2string (string_sing (c))

On Wed, Jul 2, 2014 at 6:28 PM, Brandon Barker brand...@gmail.com wrote:

Could you include your code? I’m not sure what is meant by your last
statement about ‘\0’.

Brandon Barker
brand...@gmail.com

On Wed, Jul 2, 2014 at 8:54 AM, Chotu S cho...@gmail.com wrote:

I know how to make a string from a given char , but I need to know how
to do it in ATS without using C snippets.

Say I have function make_string that takes a char and return a string :

fun make_string (c : char) : string

This function return empty string when c = 0

Example : make_string (‘a’) => “a”
make_string (‘\0’) => “”

In particular I want to make use of “string_sing” inside the function.

I am unable to compile the above function even when I take ‘\0’ into
account.

Thanks


You received this message because you are subscribed to the Google
Groups “ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to ats-lang...@googlegroups.com.
To post to this group, send email to ats-l...@googlegroups.com.

Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/
msgid/ats-lang-users/CAAZxu4yOBaEb6ZJze6NK-_
So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4yOBaEb6ZJze6NK-_So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com?utm_medium=email&utm_source=footer
.


You received this message because you are subscribed to the Google
Groups “ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to ats-lang...@googlegroups.com.
To post to this group, send email to ats-l...@googlegroups.com.

Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/
msgid/ats-lang-users/CAORbNRqPyNPFLxx5LbQQwGnNUgHsc
qQiTnU4-A6y_2gd536EkA%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAORbNRqPyNPFLxx5LbQQwGnNUgHscqQiTnU4-A6y_2gd536EkA%40mail.gmail.com?utm_medium=email&utm_source=footer
.


You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/adc353f4-c4a1-4727-ba88-1c0dccb634f4%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/adc353f4-c4a1-4727-ba88-1c0dccb634f4%40googlegroups.com?utm_medium=email&utm_source=footer
.

string_sing can only be applied to a non-zero char:

fun make_string (c: char) = let
val c = g1ofg0 (c)
in
if iseqz (c) then “” else strnptr2string(string_sing(c))
endOn Wednesday, July 2, 2014 9:11:25 AM UTC-4, Chotu S wrote:

I meant something like this :

fun make_string (c : char) : string =
if c = ‘\0’ then “”
else strnptr2string (string_sing (c))

On Wed, Jul 2, 2014 at 6:28 PM, Brandon Barker <brand...@gmail.com <javascript:>> wrote:

Could you include your code? I’m not sure what is meant by your last
statement about ‘\0’.

Brandon Barker
brand...@gmail.com <javascript:>

On Wed, Jul 2, 2014 at 8:54 AM, Chotu S <cho...@gmail.com <javascript:>> wrote:

I know how to make a string from a given char , but I need to know how
to do it in ATS without using C snippets.

Say I have function make_string that takes a char and return a string :

fun make_string (c : char) : string

This function return empty string when c = 0

Example : make_string (‘a’) => “a”
make_string (‘\0’) => “”

In particular I want to make use of “string_sing” inside the function.

I am unable to compile the above function even when I take ‘\0’ into
account.

Thanks


You received this message because you are subscribed to the Google
Groups “ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to ats-lang...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4yOBaEb6ZJze6NK-_So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAAZxu4yOBaEb6ZJze6NK-_So93LxQCMAZAV-bPB02-fS8TvOmw%40mail.gmail.com?utm_medium=email&utm_source=footer
.


You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAORbNRqPyNPFLxx5LbQQwGnNUgHscqQiTnU4-A6y_2gd536EkA%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAORbNRqPyNPFLxx5LbQQwGnNUgHscqQiTnU4-A6y_2gd536EkA%40mail.gmail.com?utm_medium=email&utm_source=footer
.