Skip to content

Commit

Permalink
add AppleScript
Browse files Browse the repository at this point in the history
  • Loading branch information
taisukef committed Dec 7, 2024
1 parent ca45f4a commit 32fff56
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 2 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ the narrower the range, the longer the code, and the forward matching will tell

## Supported Languages

106 languages supported
107 languages supported

([JavaScript](#in-JavaScript-HTML) / [TypeScript](#in-TypeScript-Deno) / [Zen](#in-Zen) / [C](#in-C) / [C++](#in-C-1) / [C#](#in-C-2) / [Swift](#in-Swift) / [Java](#in-Java) / [Python](#in-Python) / [Ruby](#in-Ruby) / [PHP](#in-PHP) / [Go](#in-Go) / [Kotlin](#in-Kotlin) / [Dart](#in-Dart) / [Rust](#in-Rust) / [Haskell](#in-haskell-ghc-84x-or-later) / [OpenVBS](#in-OpenVBS) / [VBScript](#in-VBScript) / [Visual Basic](#in-Visual-Basic) / [Scala](#in-Scala) / [R](#in-R) / [GAS](#in-GAS-Google-App-Script) / [Nim](#in-Nim) / [Lua](#in-Lua) / [Perl](#in-Perl) / [Elixir](#in-Elixir) / [Groovy](#in-Groovy) / [D](#in-D) / [Julia](#in-Julia) / [Racket](#in-Racket) / [OCaml](#in-OCaml) / [Erlang](#in-Erlang) / [Clojure](#in-Clojure) / [F#](#in-F) / [Haxe](#in-Haxe) / [Scheme](#in-Scheme-R6RS) / [Common Lisp](#in-Common-Lisp) / [Elm](#in-Elm) / [Hack](#in-Hack) / [PureScript](#in-PureScript) / [CoffeeScript](#in-CoffeeScript) / [Objective-C](#in-Objective-C) / [Frege](#in-Frege) / [Eiffel](#in-Eiffel) / [Ada](#in-Ada) / [Free Pascal](#in-Free-Pascal) / [Crystal](#in-Crystal) / [Forth](#in-Forth) / [Bash](#in-Bash) / [AWK](#in-AWK) / [Vim script](#in-Vim-script) / [Vim9 script](#in-Vim9-script) / [IchigoJam BASIC](#in-IchigoJam-BASIC) / [GnuCOBOL](#in-GnuCOBOL) / [MoonScript](#in-MoonScript) / [Octave](#in-Octave) / [Emacs Lisp](#in-Emacs-Lisp) / [Fortran 90](#in-Fortran-90) / [MariaDB SQL/PSM](#in-MariaDB-SQL) / [PL/pgSQL](#in-PLpgSQL) / [Tcl](#in-Tcl) / [V](#in-V) / [Pike](#in-Pike) / [Io](#in-Io) / [Wren](#in-Wren) / [GNU Smalltalk](#in-GNU-Smalltalk) / [JScript](#in-JScript) / [Pharo](#in-Pharo) / [Scratch](#in-Scratch) / [Standard ML](#in-Standard-ML) / [なでしこ](#in-なでしこ) / [Kuin](#in-Kuin) / [ClojureScript](#in-ClojureScript) / [HSP](#in-HSP) / [Reason](#in-Reason) / [THPL](#in-THPL) / [Janet](#in-Janet) / [Phel](#in-Phel) / [Raku](#in-Raku) / [文言](#in-文言) / [Vala](#in-Vala) / [SmileBASIC](#in-SmileBASIC) / [Small Basic](#in-Small-Basic) / [Flix](#in-Flix) / [PowerShell](#in-PowerShell) / [Koka](#in-Koka) / [Zig](#in-Zig) / [BanchaScript](#in-BanchaScript) / [AssemblyScript](#in-AssemblyScript) / [Clawn](#in-Clawn) / [FORTRAN 77](#in-FORTRAN-77) / [orelang](#in-orelang) / [Laze](#in-Laze) / [WebAssembly](#in-WebAssembly) / [Nelua](#in-Nelua) / [Roland](#in-Roland) / [ReScript](#in-ReScript) / [Effekt](#in-Effekt) / [Ceylon](#in-Ceylon) / [Mochi](#in-Mochi) / [Neko](#in-Neko) / [NekoML](#in-NekoML) / [LLVM IR](#in-LLVM-IR) / [Mojo](#in-Mojo) / [Pkl](#in-Pkl) / [Jsonnet](#in-Jsonnet))
([JavaScript](#in-JavaScript-HTML) / [TypeScript](#in-TypeScript-Deno) / [Zen](#in-Zen) / [C](#in-C) / [C++](#in-C-1) / [C#](#in-C-2) / [Swift](#in-Swift) / [Java](#in-Java) / [Python](#in-Python) / [Ruby](#in-Ruby) / [PHP](#in-PHP) / [Go](#in-Go) / [Kotlin](#in-Kotlin) / [Dart](#in-Dart) / [Rust](#in-Rust) / [Haskell](#in-haskell-ghc-84x-or-later) / [OpenVBS](#in-OpenVBS) / [VBScript](#in-VBScript) / [Visual Basic](#in-Visual-Basic) / [Scala](#in-Scala) / [R](#in-R) / [GAS](#in-GAS-Google-App-Script) / [Nim](#in-Nim) / [Lua](#in-Lua) / [Perl](#in-Perl) / [Elixir](#in-Elixir) / [Groovy](#in-Groovy) / [D](#in-D) / [Julia](#in-Julia) / [Racket](#in-Racket) / [OCaml](#in-OCaml) / [Erlang](#in-Erlang) / [Clojure](#in-Clojure) / [F#](#in-F) / [Haxe](#in-Haxe) / [Scheme](#in-Scheme-R6RS) / [Common Lisp](#in-Common-Lisp) / [Elm](#in-Elm) / [Hack](#in-Hack) / [PureScript](#in-PureScript) / [CoffeeScript](#in-CoffeeScript) / [Objective-C](#in-Objective-C) / [Frege](#in-Frege) / [Eiffel](#in-Eiffel) / [Ada](#in-Ada) / [Free Pascal](#in-Free-Pascal) / [Crystal](#in-Crystal) / [Forth](#in-Forth) / [Bash](#in-Bash) / [AWK](#in-AWK) / [Vim script](#in-Vim-script) / [Vim9 script](#in-Vim9-script) / [IchigoJam BASIC](#in-IchigoJam-BASIC) / [GnuCOBOL](#in-GnuCOBOL) / [MoonScript](#in-MoonScript) / [Octave](#in-Octave) / [Emacs Lisp](#in-Emacs-Lisp) / [Fortran 90](#in-Fortran-90) / [MariaDB SQL/PSM](#in-MariaDB-SQL) / [PL/pgSQL](#in-PLpgSQL) / [Tcl](#in-Tcl) / [V](#in-V) / [Pike](#in-Pike) / [Io](#in-Io) / [Wren](#in-Wren) / [GNU Smalltalk](#in-GNU-Smalltalk) / [JScript](#in-JScript) / [Pharo](#in-Pharo) / [Scratch](#in-Scratch) / [Standard ML](#in-Standard-ML) / [なでしこ](#in-なでしこ) / [Kuin](#in-Kuin) / [ClojureScript](#in-ClojureScript) / [HSP](#in-HSP) / [Reason](#in-Reason) / [THPL](#in-THPL) / [Janet](#in-Janet) / [Phel](#in-Phel) / [Raku](#in-Raku) / [文言](#in-文言) / [Vala](#in-Vala) / [SmileBASIC](#in-SmileBASIC) / [Small Basic](#in-Small-Basic) / [Flix](#in-Flix) / [PowerShell](#in-PowerShell) / [Koka](#in-Koka) / [Zig](#in-Zig) / [BanchaScript](#in-BanchaScript) / [AssemblyScript](#in-AssemblyScript) / [Clawn](#in-Clawn) / [FORTRAN 77](#in-FORTRAN-77) / [orelang](#in-orelang) / [Laze](#in-Laze) / [WebAssembly](#in-WebAssembly) / [Nelua](#in-Nelua) / [Roland](#in-Roland) / [ReScript](#in-ReScript) / [Effekt](#in-Effekt) / [Ceylon](#in-Ceylon) / [Mochi](#in-Mochi) / [Neko](#in-Neko) / [NekoML](#in-NekoML) / [LLVM IR](#in-LLVM-IR) / [Mojo](#in-Mojo) / [Pkl](#in-Pkl) / [Jsonnet](#in-Jsonnet) / [AppleScript](#in-AppleScript))

supported languages list / サポート言語一覧
https://github.com/taisukef/Geo3x3/blob/master/langlist.csv
Expand Down Expand Up @@ -2401,6 +2401,23 @@ to run:
$ jsonnet simple_geo3x3.jsonnet
```

## in AppleScript
[AppleScript](https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html)
[geo3x3_encode.applescript](https://github.com/taisukef/Geo3x3/blob/master/geo3x3_encode.applescript),
[geo3x3_decode.applescript](https://github.com/taisukef/Geo3x3/blob/master/geo3x3_decode.applescript)
```
log encodeGeo3x3(35.65858, 139.745433, 14)
log decodeGeo3x3("E9139659937288")
```
setup:

to run:
```bash
$ osascript geo3x3_encode.applescript
$ osascript geo3x3_decode.applescript
```

## How to contribute
1. add a lang
2. add a lang section in [README.md](README.md) (ex. [Neko](#in-Neko))
Expand Down
38 changes: 38 additions & 0 deletions geo3x3_decode.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on decodeGeo3x3(code)
set unit to 180.0
set lat to 0.0
set lng to 0.0
set level to 1

set begin to 0
set flg to false
set c to character 1 of code
if c = "-" or c = "W" then
set flg to true
set begin to 1
else if c = "+" or c = "E" then
set begin to 1
end if
set clen to length of code
repeat with i from begin to clen - 1
set c to character (1 + i) of code
set n to c as integer
if n <= 0 then
break
end if
set unit to unit / 3
set n to n - 1
set lng to lng + n mod 3 * unit
set lat to lat + n div 3 * unit
set level to level + 1
end repeat
set lat to lat + unit / 2
set lng to lng + unit / 2
set lat to lat - 90.0
if flg then
set lng to lng - 180.0
end if
return { lat: lat, lng: lng, level: level, unit: unit }
end decodeGeo3x3

log decodeGeo3x3("E9139659937288")
26 changes: 26 additions & 0 deletions geo3x3_encode.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on encodeGeo3x3(lat, lng, level)
if level < 1 then
return ""
end if
set res to ""
set lng2 to lng
if lng >= 0 then
set res to "E"
else
set res to "W"
set lng2 to lng2 + 180
end if
set lat2 to lat + 90.0
set unit to 180.0
repeat level - 1 times
set unit to unit / 3
set x to lng2 div unit
set y to lat2 div unit
set res to res & (x + y * 3 + 1)
set lng2 to lng2 - x * unit
set lat2 to lat2 - y * unit
end repeat
return res
end encodeGeo3x3

log encodeGeo3x3(35.65858, 139.745433, 14)
1 change: 1 addition & 0 deletions langlist.csv
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@ LLVM IR,ll,blacket,none,none,compile,https://github.com/taisukef/Geo3x3/blob/mas
Mojo,mojo,indent,var,let,compile,https://github.com/taisukef/Geo3x3/blob/master/geo3x3.mojo
Pkl,pkl,none,none,let,script,https://github.com/taisukef/Geo3x3/blob/master/geo3x3.pkl
Jsonnet,"jsonnet,libsonnet",none,none,local,script,https://github.com/taisukef/Geo3x3/blob/master/geo3x3.libsonnet
AppleScript,applescript,end,none,none,none,https://github.com/taisukef/Geo3x3/blob/master/geo3x3_encode.applescript

0 comments on commit 32fff56

Please sign in to comment.