Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

akira

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

akira

toy functional language that transpiles to JavaScript

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

akira

Functional language that transpiles to JavaScript.

Syntax

Literals

-- String
'i am a string'

-- Number
2.0
3

-- Boolean
true
false

-- Null
none

-- Maps
cat = {
  @name 'Luna'
  @age 2
}

-- Lists
[1, 2, 3, 4]
[1 2 3 4]
['h', 'e', 'l', 'l', 'o']

-- Regular Expressions
/[A-Z]+/g

Functions

sum = fn [a b] a + b

-- invoking sum...
sum: 1, 2

-- functions can also be invoked with pipes
sum: 1, 2 | print        -- print(sum(1, 2))

-- multiple expressions can be piped together
1 | id | print           -- print(id(1))

-- previous args are carried over into function calls
-- also have some sugar functions such for operations like comparisons.
1 | sum: 2 | (== 3)   -- sum(2, 1) == 3

-- function expressions with a body
fib = fn [n] {
  if n < 2
    then n
    else (fib: n - 1) + (fib: n - 2)
}

-- IIFE
(fn [] {
  number-of-balloons = 99
}): none

-- Anonymous functions
fn [x] x * x

-- we can pass those as args
call-function = fn [f arg] f: arg
call-function: (fn [x] x * x), 9      -- 81

-- There's also Pattern Matching and Guards
fact = fn [n]
  1 ? 1
  else ? n * (fact: n - 1)

-- splits up the list into x = head(list) and xs = tail(list)
sort-even-odd = fn [[x, & xs]]
  not x ? []
  odd: x ? (sort-even-odd: xs) ++ [x]
  else ? x +: (sort-even-odd: xs)

  [1 2 3 4 5 6] | sort-even-odd | assert-deep: [2 4 6 5 3 1]

License

MIT

FAQs

Package last updated on 28 Oct 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc