:erlang.list_to_atom("roster") error when accessing mnesia table - erlang

I am trying get mnesia table info from elixir shell.
I have tried to convert the string to atom.
String.to_atom("roster")
I have tried to pass string as list ["roster"]
command -
:ejabberd_admin.mnesia_table_info("roster")
error
ArgumentError
:erlang.list_to_atom("roster")

Erlang expects a charlist there, not a binary. Use single quotes:
:ejabberd_admin.mnesia_table_info('roster')
Also: Kernel.to_charlist/1, ~c/2.
Documentation on charlists on official site.
Example:
iex(1)> :erlang.list_to_atom("roster")
** (ArgumentError) argument error
:erlang.list_to_atom("roster")
iex(1)> :erlang.list_to_atom('roster')
:roster

Related

In Bazel, is it possible to use a function output as input to a load statement?

In Bazel, is it possible to use simple functions and variables as input to a load statement?
For example:
my_workspace = "a" + "b"
load(my_workspace, "foo")
load(my_workspace, "bar")
WARNING: Target pattern parsing failed.
ERROR: error loading package 'loadtest/simple': malformed load statements
The exact error message might have changed with version, I'd see:
syntax error at 'my_workspace': expected string literal
but no, you cannot use anything but string literal as per docs:
Use the load statement to import a symbol from an extension.
...
Arguments must be string literals (no variable)...

Read a list from stream using Yap-Prolog

I want to run a (python3) process from my (yap) prolog script and read its output formatted as a list of integers, e.g. [1,2,3,4,5,6].
This is what I do:
process_create(path(python3),
['my_script.py', MyParam],
[stdout(pipe(Out))]),
read(Out, OutputList),
close(Out).
However, it fails at read/2 predicate with the error:
PL_unify_term: PL_int64 not supported
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe
I am sure that I can run the process correctly because with [stdout(std)] parameter given to process_create the program outputs [1,2,3,4,5,6] as expected.
Weird thing is that when I change the process to output some constant term (as constant_term) it still gives the same PL_int64 error. Appending a dot to the process' output ([1,2,3,4,5,6].) doesn't solve the error. Using read_term/3 gives the same error. read_string/3 is undefined in YAP-Prolog.
How can I solve this problem?
After asking at the yap-users mailing list I got the solution.
Re-compiled YAP Prolog 6.2.2 with libGMP option and now it works. It may also occur in 32-bit YAP.

SQLite syntax error with Encrypted-Core-Data

I've been running into a syntax error for a very long time now and I am unsure as to what could be causing it. The debug log is as follows:
SQL DEBUG: SELECT ecdImages.checkSum, ecdImages.creationDate, ecdImages.filename, ecdImages.height, ecdImages.latitude, ecdImages.locationString, ecdImages.longitude, ecdImages.order, ecdImages.photoId, ecdImages.photoLogValues, ecdImages.requiresDeletion, ecdImages.requiresUpload, ecdImages.rotationAngle, ecdImages.scale, ecdImages.source, ecdImages.timestamp, ecdImages.title, ecdImages.transform, ecdImages.width, ecdImages.x, ecdImages.y, ecdImages.book__objectid, ecdImages.page__objectid FROM ecdImages WHERE ecdImages.__objectid=?;
could not prepare statement: near "order": syntax error
Order is of type Integer 16 and for your reference, I am currently using Encrypted-Core-Data as found on github. Any thoughts?
As pointed out by CL in the comments, I was using a reserved keyword. Refer to SQLite Keywords.

Idl readcol function, using delimeter without syntax error

Im trying to use idl to read a file, so im using the readcol command. However, in my file i use | as a delimiter, but continually get syntax errors. Heres my latest attempt:
readcol,'kcorrins.txt',uband, gband, rband, iband, zband, $
ubanderr, gbanerr, rbanderr, ibanderr, zbanderr, adjredshift, $
SKIPLINE=1, DELIMITER=|
could someone post an example of the proper syntax for using the delimiter in this way?
You need to quote the delimiter:
readcol,'kcorrins.txt',uband, gband, rband, iband, zband, $
ubanderr, gbanerr, rbanderr, ibanderr, zbanderr, adjredshift, $
SKIPLINE=1, DELIMITER='|'

Obtain a full list of valid system_info atoms

I've guessed a couple of the erlang:system_info/1 variants such as:
10> erlang:system_info(schedulers).
4
11> erlang:system_info(cpu).
** exception error: bad argument
in function erlang:system_info/1
called as erlang:system_info(cpu)
12> erlang:system_info(cpu_arch).
** exception error: bad argument
in function erlang:system_info/1
called as erlang:system_info(cpu_arch)
13> erlang:system_info(memory).
** exception error: bad argument
in function erlang:system_info/1
called as erlang:system_info(memory)
14> erlang:system_info(version).
"5.10.4"
But is there a way, either via introspection, or a global database of some sort, to list all the available system_info arguments ?
Refer to the documentation for erlang:system_info/1. It's listed over several sections with descriptions for what each atom represents. This is the most comprehensive list of supported atoms outside of the Erlang/OTP source itself (and there are a few undocumented parameters).
There is no language feature which would allow you to list all of the possible atoms.

Resources