apl

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

How would I go about counting the amount of each alphanumerical in an array? (APL)

江枫思渺然 提交于 2021-01-27 07:44:54
问题 I can't figure out how to take a matrix and count the amount of the alphanumerical values for each row. I will only be taking in matrices with the values I'm counting. For example, if I got: ABA455 7L9O36G DZLFPEI I would get something like A:2 B:1 4:1 5:2 for the first row and each row would be counted independently. I would most like to understand the operators used if you could please explain them too. Thank you. 回答1: The following should work in any mainstream APL implementation. Let's

How would I go about counting the amount of each alphanumerical in an array? (APL)

一个人想着一个人 提交于 2021-01-27 07:43:05
问题 I can't figure out how to take a matrix and count the amount of the alphanumerical values for each row. I will only be taking in matrices with the values I'm counting. For example, if I got: ABA455 7L9O36G DZLFPEI I would get something like A:2 B:1 4:1 5:2 for the first row and each row would be counted independently. I would most like to understand the operators used if you could please explain them too. Thank you. 回答1: The following should work in any mainstream APL implementation. Let's

Convert date (year month day) to day count

断了今生、忘了曾经 提交于 2020-01-15 09:01:07
问题 I would like a function (using Gregorian calendar rules) given 3⍴⎕TS would return 1+ the number of days since 1 1 1. EG if the function were named X : X¨ (1 1 1) (1 12 31) (2 12 31) (3 12 31) (4 12 31) 1 365 730 1095 1461 I need this so I can subtract two dates to find the number of days between them. 回答1: Please see the following example - function X assumes index origin 1 as follows: r←X b r←(0 31 59 90 120 151 181 212 243 273 304 334)[b[2]] r←r+b[3]+(365×b[1]-1)+-/⌊(b[1]-3>b[2])÷4 100 400

Convert date (year month day) to day count

耗尽温柔 提交于 2020-01-15 09:00:12
问题 I would like a function (using Gregorian calendar rules) given 3⍴⎕TS would return 1+ the number of days since 1 1 1. EG if the function were named X : X¨ (1 1 1) (1 12 31) (2 12 31) (3 12 31) (4 12 31) 1 365 730 1095 1461 I need this so I can subtract two dates to find the number of days between them. 回答1: Please see the following example - function X assumes index origin 1 as follows: r←X b r←(0 31 59 90 120 151 181 212 243 273 304 334)[b[2]] r←r+b[3]+(365×b[1]-1)+-/⌊(b[1]-3>b[2])÷4 100 400

Cross-platforming C++ functions to APL

旧巷老猫 提交于 2020-01-05 08:37:11
问题 I am currently writing C++ programs for APL. Up to now, what I've been doing is creating a function in APL, which runs the command prompt and calls the executable, with input and output files it creates as parameters and in turn, the C++ executable is programmed to open the input file, read the input and store the output in the output file, which is fetched by the APL function and stored in one or more variables. The problem with this method is that, when I use simpler functions which will be

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 split a number into its digits in APL

a 夏天 提交于 2019-12-23 17:05:17
问题 In APL, how can I split an integer or number into a vector containing its digits? What is the most concise (shortest) way of doing this? 回答1: You can use the inverse of Decode with base 10: 10⊥⍣¯1⊢ since Decode would take in as many digits as needed and decode them, its inverse would take a number and encode it to as many digits as needed, or, with ⎕IO←0 , you can try to find the indexes of the formatted number inside the digits vector: ⎕D⍳⍕ Demo for both solutions. This is better than the

In SQL, How can I generate every possible unique combination of 5!56?

删除回忆录丶 提交于 2019-12-23 13:34:11
问题 I have a TABLE "elements" with one COLUMN "number", type SMALLINT that contains numbers 1 thru 56. How can I generate unique sets of 5 numbers of every possible combination from 1 to 56, using an SQL statement? In APL (programming language) a simple dyadic function 5!56 does the trick! EDIT: In good ole MS-DOS QBASIC, I accomplished it like this: 10 OPEN "C:\5NUMBERS.OUT" FOR OUTPUT ACCESS READ WRITE AS #1 12 LET SER = 0 15 LET E = 56 30 FOR B5 = 5 TO E 40 FOR B4 = 4 TO E 50 FOR B3 = 3 TO E