forked from metaeducation/rebol-issues
-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating vectors with external blocks #2616
Labels
Comments
Why you don't use the block directly? You should not copy values one by one as you do in your code. block2Vector: function[type [word!] block [block!]][
make vector! compose/only select make map! [
int8 [integer! 8 (block)]
int16 [integer! 16 (block)]
int32 [integer! 32 (block)]
int64 [integer! 64 (block)]
uint8 [unsigned integer! 8 (block)]
uint16 [unsigned integer! 16 (block)]
uint32 [unsigned integer! 32 (block)]
uint64 [unsigned integer! 64 (block)]
float32 [decimal! 32 (block)]
float64 [decimal! 64 (block)]
] type
] Then: >> b: [#"A" #"B" #"a" #"b"]
== [#"A" #"B" #"a" #"b"]
>> block2vector 'float32 b
== make vector! [decimal! 32 4 [65.0 66.0 97.0 98.0]]
>> block2vector 'uint8 b
== make vector! [unsigned integer! 8 4 [65 66 97 98]] |
Maybe the make vector dialect could be smarter and accept the types as used in the construction syntax already. And resolve the data from a variable without need to use make vector! [uint16! :data] Which would be same like: make vector! compose/only [unsigned integer! 16 (data)] |
Elegant :)
[image001.png][image002.png]
François Jouen
<https://univ-psl.fr/>
École Pratique des Hautes Études
Doyen Honoraire de la section des Sciences de la Vie et de la Terre
Chaire de Psychobiologie du Développement
Plateforme Réanimation Pédiatrique Raymond Poincaré. Hôpital de Garches
Laboratoire Cognitions Humaine et Artificielle
Campus Condorcet
14 cours des Humanités
15 rue Waldeck Rochet
93322 Aubervilliers cedex
06 87 13 76 81
***@***.******@***.***>
www.ephe.fr<http://www.ephe.fr/>
Le 16 août 2024 à 13:47, Oldes Huhuman ***@***.***> a écrit :
Why you don't use the block directly? You should not copy values one by one as you do in your code.
It is better to use something like:
block2Vector: function[type [word!] block [block!]][
make vector! compose/only select make map! [
int8 [integer! 8 (block)]
int16 [integer! 16 (block)]
int32 [integer! 32 (block)]
int64 [integer! 64 (block)]
uint8 [unsigned integer! 8 (block)]
uint16 [unsigned integer! 16 (block)]
uint32 [unsigned integer! 32 (block)]
uint64 [unsigned integer! 64 (block)]
float32 [decimal! 32 (block)]
float64 [decimal! 64 (block)]
] type
]
Then:
> b: [#"A" #"B" #"a" #"b"]
== [#"A" #"B" #"a" #"b"]
> block2vector 'float32 b
== make vector! [decimal! 32 4 [65.0 66.0 97.0 98.0]]
> block2vector 'uint8 b
== make vector! [unsigned integer! 8 4 [65 66 97 98]]
—
Reply to this email directly, view it on GitHub<#2616 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAXI3IODYVIGVRCEFKCQAA3ZRXREFAVCNFSM6AAAAABMR24CGWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGM2TSOJTGA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With R3 it's easy to use blocks when creating vectors when blocks are internal.
Now the question is how to use external blocks? In this case R3 returns an error. We have the possibility with such as function:
And for test, some examples:
The text was updated successfully, but these errors were encountered: