the arS adverb does work with "standard" lr in a way. Boxed linear just adds
an extra field to a lr (the 4!:0 result).
'asf' '/\' +:@+ % tieB tieB tieB
+-------+-+
|('asf')|0|
+-------+-+
|/\ |1|
+-------+-+
|(+:@+) |3|
+-------+-+
|(%) |3|
+-------+-+
relatively easy to strip away,
'asf' '/\' +:@+ % tieB tieB tieB {."1 v2a
+-------+--+------+---+
|('asf')|/\|(+:@+)|(%)|
+-------+--+------+---+
'asf' '/\' +:@+ % tieB tieB tieB {."1 v2a arS NB. gerunds of individual lrs
the toG adverb works with one expression at a time. Gets ars of modifiers and
nouns as well as verbs anonymously.
gerund to linear
3 : 'o =. i.0 for_i. y do. a =. (i 5!:0) label_. o =. o , < 5!:5 <''a'' end.
o' 'asf' '/\' +:@+ % tieB tieB tieB {."1 v2a arS
+-----+--+----+-+
|'asf'|/\|+:@+|%|
+-----+--+----+-+
inverts with arS
(3 : 'o =. i.0 for_i. y do. a =. (i 5!:0) label_. o =. o , < 5!:5 <''a'' end.
o' 'asf' '/\' +:@+ % tieB tieB tieB {."1 v2a arS) arS
----- Original Message -----
From: Marshall Lochbaum <[email protected]>
To: 'Pascal Jasmin' via Programming <[email protected]>
Sent: Saturday, February 6, 2016 10:04 PM
Subject: Re: [Jprogramming] Type conversion tool
The type system is pretty cool, and complements my conversions pretty
well. Your default types have some of the issues I was trying to address
(intify assumes <. returns an integer, and there's no support for sparse
arrays), so for anything that needs airtight types you can add something
like
int 4&numcast 4=3!:0 Must be numeric
which will fail on non-numbers and convert everything else to a (dense)
integer.
The linear boxed format looks very useful given how difficult gerunds
are to work with, but I'm only looking for conversions between standard
J representations.
Marshall
On Sun, Feb 07, 2016 at 01:26:06AM +0000, 'Pascal Jasmin' via Programming wrote:
> I made a higher level conversion tool a while back:
> https://github.com/Pascal-J/type-system-j
>
> in terms of converting gerunds and linear, I made a "linear boxed" format
> somewhat equivalent to gerunds, but easier to manipulate.
>
> eval_z_ =: 1 : ' a: 1 : m'
> lrA_z_ =: 1 : '5!:5 < ''u'''
> ncS=:3 :'z=.y 1 :y label_. 4!:0 <''z'' ' :: _2: NB. nameclass of string
> ismodstring =: 1 : 'if. 0 = 4!:0 <''u'' do. try. q =. m eval catch. 0
> return. end. 1 2 e.~ 4!:0 <''q''else. 0 end. '
>
> daF =: 1 : ('a =. (''2 : '', (quote m) , '' u'') label_. 1 : (''u 1 :'' ,
> quote a)')
>
> ncA =: 1 : 'if. 3 ~: 4!:0 < ''u'' do. if. m ismodstring do. m ; ncS m else. 0
> ;~ ''('', m lrA ,'')'' end. else. 3;~ ''('', u lrA ,'')'' end.'
>
> tieB =: 'if. (0 -.@-: 1{:: a =. v ncA) do. n =. ,: a end. u ncA,n' daF NB.
> can put nouns as long as not last element. or code it with ncA
>
>
> lrB =: 1 : ',: u ncA'
>
>
> its part of a larger framework for strand adverbs, but strings that are
> modifiers get coded as modifiers.
>
>
> '@' 3 lrB tieB
> ┌───┬─┐
> │@ │2│
> ├───┼─┤
> │(3)│0│
> └───┴─┘
>
> I don't remember if I posted these before, but I also made some utilities to
> make an ar representation from "anything", and convert lrB format to gerunds.
>
>
>
> toG =: 1 : ' if. 1 2 e.~ 1 {:: u ncA do. a =. (m) eval else. a=.u end. 5!:1 <
> ''a''' NB.makes gerund from anything. turning string modifiers into gerund
> versions.
>
> arS =: 1 : '". every ,&'' toG'' each quote^:('')'' ~: {:) each m'
>
> v2a =: 1 : ( 'a =. (''('' , u lrA ,'') m '') label_. 1 : (''m 1 :'' , quote
> a)')
>
> 'asf' '/\' +:@+ % tieB tieB tieB {."1 v2a arS
> +-------+---------+----------+-+
> |+-+---+|+-+-----+|+-+------+|%|
> ||0|asf|||4|+-+-+|||@|+--+-+|| |
> |+-+---+|| ||/|\|||| ||+:|+||| |
> | || |+-+-+||| |+--+-+|| |
> | |+-+-----+|+-+------+| |
> +-------+---------+----------+-+
>
> '/\' toG
> +---------+
> |+-+-----+|
> ||4|+-+-+||
> || ||/|\|||
> || |+-+-+||
> |+-+-----+|
> +---------+
>
> 3 toG
> +-----+
> |+-+-+|
> ||0|3||
> |+-+-+|
> +-----+
>
>
> ----- Original Message -----
> From: Marshall Lochbaum <[email protected]>
> To: [email protected]
> Sent: Saturday, February 6, 2016 4:38 PM
> Subject: [Jprogramming] Type conversion tool
>
> Based on the recent discussions about integers and floats, I decided to
> make a general tool to convert between various J types. It's hosted
> here:
>
> https://github.com/mlochbaum/JScripts/blob/master/Misc/typecast.ijs
>
> The script defines typecast, a verb to convert between types while
> maintaining J equivalence (-:), and numcast, a verb which converts
> between numeric types and guarantees no errors. Both of these operations
> are quite error-prone, so it's good to have a reference with (lightly,
> at the moment) tested verbs to perform them.
>
> My goal is to eventually have a glossary of ways to convert between
> types. I will probably make typecast suggest alternative conversion
> methods if it fails on a particular argument. So I'm curious if anyone
> knows of interesting and useful ways to convert types. The ones I know
> of are:
>
> - Conversions (3!:x) from numbers to bytes
> - (0&~:) to convert numbers to booleans
> - (mod 2^64) conversion from exact to 64-bit integer
> - Representations (5!:x) from nouns (or other parts of speech) to
> strings or boxes.
> - Gerund representation for a verb
> - The sneaky trick which boxes a part of speech directly
>
> Any others?
>
> Marshall
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm