cat123456
cat123456

Reputation: 61

How to convert string list with number list each other in Prolog?

I want to convert a string list to number list. It is implemented in Prolog.

For example:

L = ['21', '45', '06']

should become

X = [21, 45, 6]

How to code this in Prolog?

Upvotes: 1

Views: 98

Answers (1)

damianodamiano
damianodamiano

Reputation: 2662

In one line: maplist(atom_number,L,LO) using maplist/3 and atom_number/2.

Upvotes: 2

Related Questions