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: wang_feng_bro AT 163.com
  • To: k-user AT lists.cs.illinois.edu, Sandeep Dasgupta <sdasgup3 AT illinois.edu>
  • Cc: sdasgup3 AT illinois.edu
  • Subject: Re: [[K-user] ] How to return a list
  • Date: Wed, 25 Apr 2018 16:44:05 +0800
  • Authentication-results: illinois.edu; spf=pass smtp.mailfrom=wang_feng_bro AT 163.com; dkim=pass header.d=163.com header.s=s110527; dmarc=none

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