dyalog

How do I get current timestamp in seconds?

流过昼夜 提交于 2021-01-28 05:46:17
问题 In Dyalog APL I can use the function ⎕TS to get the current year, month, day, hour, minute, second etc, but is there a way to get the current timestamp in seconds from e.g. 1970-01-01 (Unix timestamp)? 回答1: Using days from https://dfns.dyalog.com/n_days.htm )copy dfns days C:\Program Files\Dyalog\Dyalog APL-64 17.1 Unicode\ws\dfns.dws saved Wed Aug 21 19:40:24 2019 86400×(days ⎕TS)-(days 1970 1 1) 1570618030 Could also use the over ⍥ operator, coming in Dyalog version 18.0 )copy dfns days C:

Multi-line text values in Dyalog APL

大憨熊 提交于 2021-01-27 18:22:08
问题 How to code a multi-line text value in Dyalog APL? I want to code something like this: query←' SELECT * FROM SOME_TABLE ' to be able to copy this text to SQL Developer and back. I know that I could code it this way: query←'' query,←'SELECT * ' query,←'FROM SOME_TABLE ' But it would not allow me to copy this text to SQL Developer and back easily. Is it possible to temporary override the newline character in Dyalog APL function source code? 回答1: S←{a←⍺⍺⋄,⎕cr'a'} query←{ SELECT * FROM Some_Table

Syntax error when attempting to amend a string with indexing

风流意气都作罢 提交于 2019-12-25 00:34:16
问题 I'm studying APL from here. Why am I getting this syntax error? 'computer' [ 1 2 3 ] ← 'COM' SYNTAX ERROR 'computer'[1 2 3]←'COM' ^ But if I save 'computer' in a variable I don't get the error: T ← 'computer' T computer T[1 2 3] ← 'COM' T COMputer What am I doing wrong? 回答1: 'computer' is a constant, and you can't change the value of a constant itself, only the current value of a variable. Think about it: If you could assign to 'computer' , then next time you wrote 'computer' , would you

How to use rank operator instead of each in APL

陌路散爱 提交于 2019-12-22 10:43:46
问题 I have dummytxt←'abcdefghijk' texttoadd←'down' rfikv←20 30 50 and need following output defghijk20down defghijk30down defghijk50down I can do it with: scenv←(¯10↑¨(⊂dummytxt),¨⍕¨rfikv),¨⊂texttoadd but please help me to write without each operator but using rank ⍤ I use Dyalog APL, but please do not use trains. Thank you 回答1: Expressions using Each , like f¨x , can be expressed in terms of Rank as {⊂f⊃⍵}⍤0⊢x (note that ⊢ is to separate the array right operand, 0 from the array right argument x

Error Handling in APL

 ̄綄美尐妖づ 提交于 2019-12-12 12:22:59
问题 I am currently working on an APL program for a class and have run into an issue with error handling. In a function I made, I want to check to see that the input is an integer. If it is not, I want to return an error message and not run the rest of the function. So far, I compare to see if it's equal to the floor of itself. If not, I don't want the function to run and want it to stop. It works if I put 4.2 and gives an error message, but doesn't work if I put something like 'A' in or 'ABCDEF'

Problems when trying to use arrays in APL. What have I missed?

爷,独闯天下 提交于 2019-12-10 18:58:25
问题 I obviously have missed some things about how to extract elements from arrays in APL and hope that someone can see what I have missed and how I should do to get the expected results in a way that I can reproduce in a meaningful way. I am relatively new in learning APL and I am more used to languages like Python and C. The data types and array manipulating tools in APL seem to confuse me, a little. Consider the following code and please tell why the expected (by me) result, ┌→─────┐ │42 666│ └

How to build own Each operator using Rank operator in Dyalog APL

送分小仙女□ 提交于 2019-12-07 17:16:51
问题 I saw answer in this question How to use rank operator instead of each in APL how to build own Each operator using Rank ⍤ . Monadic Each f¨x can be represented as {⊂f⊃⍵}⍤0⊢x Dyadic Each x f¨y can be represented as x{⊂(⊃⍺)f(⊃⍵)}⍤0⊢y In terms of this please answer following questions: Why Each ¨ operator can be represented as Each←{⍺←⊢ ⋄ ⍺ ⍺⍺{×⎕NC'⍺':⊂(⊃⍺)⍺⍺(⊃⍵) ⋄ ⊂⍺⍺⊃⍵}⍤0⊢⍵} What means ⍺⍺ in the expression above Thank you in advance for your answers. 回答1: This definition basically combines the

How to use rank operator instead of each in APL

梦想的初衷 提交于 2019-12-05 20:19:54
I have dummytxt←'abcdefghijk' texttoadd←'down' rfikv←20 30 50 and need following output defghijk20down defghijk30down defghijk50down I can do it with: scenv←(¯10↑¨(⊂dummytxt),¨⍕¨rfikv),¨⊂texttoadd but please help me to write without each operator but using rank ⍤ I use Dyalog APL, but please do not use trains. Thank you Expressions using Each , like f¨x , can be expressed in terms of Rank as {⊂f⊃⍵}⍤0⊢x (note that ⊢ is to separate the array right operand, 0 from the array right argument x ). In other words, on the scalars of the argument we: disclose the scalar: ⊃⍵ apply the function: f⊃⍵

How to build own Each operator using Rank operator in Dyalog APL

喜欢而已 提交于 2019-12-05 19:20:21
I saw answer in this question How to use rank operator instead of each in APL how to build own Each operator using Rank ⍤ . Monadic Each f¨x can be represented as {⊂f⊃⍵}⍤0⊢x Dyadic Each x f¨y can be represented as x{⊂(⊃⍺)f(⊃⍵)}⍤0⊢y In terms of this please answer following questions: Why Each ¨ operator can be represented as Each←{⍺←⊢ ⋄ ⍺ ⍺⍺{×⎕NC'⍺':⊂(⊃⍺)⍺⍺(⊃⍵) ⋄ ⊂⍺⍺⊃⍵}⍤0⊢⍵} What means ⍺⍺ in the expression above Thank you in advance for your answers. This definition basically combines the monadic and dyadic cases which you listed above. ×⎕NC'⍺' will return 1 if ⍺ exists and 0 otherwise, so it