How do you write a literal function?

36 views
Skip to first unread message

Thomas Gebert

unread,
Aug 11, 2020, 1:50:56 PM8/11/20
to tlaplus
Howdy. 

If I want to write a literal definition of a function that has a sequential set of integers as its domain, I can of course use the tuple syntax `<<"a", "b", "c">>`, but how might I go about doing this with anything but an integer index, e.g. a string? For example, what if I wanted to have something more or less akin to this in javascript: 

var myObj = {
  "foo":"bar",
  "baz": "blah"
}

myObj["foo"] // "bar". 


Hillel Wayne

unread,
Aug 11, 2020, 5:54:26 PM8/11/20
to tla...@googlegroups.com

Hi Thomas,

You can use a structure:

Op == [foo |-> "bar", baz |-> "blah"]

H

--
You received this message because you are subscribed to the Google Groups "tlaplus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tlaplus+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tlaplus/f57ef2a7-212b-465e-a3de-fac154d233cco%40googlegroups.com.

Thomas Gebert

unread,
Aug 11, 2020, 9:23:08 PM8/11/20
to tlaplus
That works...Thanks! For some reason, I thought that a set had to be on the left side of the |->...must have confused it for ->. 

On Tuesday, August 11, 2020 at 5:54:26 PM UTC-4, Hillel Wayne wrote:

Hi Thomas,

You can use a structure:

Op == [foo |-> "bar", baz |-> "blah"]

H

On 8/11/2020 12:50 PM, Thomas Gebert wrote:
Howdy. 

If I want to write a literal definition of a function that has a sequential set of integers as its domain, I can of course use the tuple syntax `<<"a", "b", "c">>`, but how might I go about doing this with anything but an integer index, e.g. a string? For example, what if I wanted to have something more or less akin to this in javascript: 

var myObj = {
  "foo":"bar",
  "baz": "blah"
}

myObj["foo"] // "bar". 


--
You received this message because you are subscribed to the Google Groups "tlaplus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tla...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages