Skip to Content.
Sympa Menu

k-user - Re: [[K-user] ] How to return a list

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [[K-user] ] How to return a list


Chronological Thread 
  • From: Sandeep Dasgupta <sdasgup3 AT illinois.edu>
  • To: <wang_feng_bro AT 163.com>, <k-user AT lists.cs.illinois.edu>
  • Cc: <sdasgup3 AT illinois.edu>
  • Subject: Re: [[K-user] ] How to return a list
  • Date: Wed, 25 Apr 2018 11:22:14 -0500
  • Authentication-results: illinois.edu; spf=pass smtp.mailfrom=sdasgup3 AT illinois.edu; dmarc=pass header.from=illinois.edu

Dear Jerry,
Ah! I thought you wanted a more meaningful delimiter that just a ".".
I believe you already know that what you got (int, int, .Type) is indeed a representation of list as you asked for in the first place and  The input (1,2,3) is  internally  represented as (1,2,3, .Vals) only.

Sorry that I don't have insights on how to get the output representation same as  how the input is expected (i.e. without dot). Hopefully u will get the reply soon.

Regards,
Sandeep

On 04/25/2018 03:44 AM, wang_feng_bro AT 163.com wrote:
Unfortunately, it doesn’t work and returns (int, (int, (int .Types)) now.
On Apr 25, 2018, 2:06 AM +0800, Sandeep Dasgupta <sdasgup3 AT illinois.edu>, wrote:
Dear Jerry

Can u please try

rule getAllTypes(.Vals) => .Types


Regards,
Sandeep

On 04/24/2018 09:00 AM, wang_feng_bro AT 163.com wrote:
Hi all,

I want to implement a function in K, which takes a list as the input and also return a list. 
For instance, the input is : (1,2,3) and the expecting output is (int, int ,int ). However, my function returns (int, (int, (int .)).
The definitions are :

syntax Type ::= “int” | ….
syntax Types ::= List{Type, ",”}


syntax Types ::= getAllTypes(Vals)  [function]
rule getAllTypes(V:Val, Vs:Vals) => getType(V), getAllTypes(Vs)
rule getAllTypes(.Vals) => . 

where getType() is just an auxiliary function. 

Please help me… Thanks !

Jerry







Archive powered by MHonArc 2.6.19.

Top of Page