This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ack = method x, y, | |
| if x == 0 return y + 1. | |
| if y == 0 return ack x - 1, 1. | |
| ack x - 1, ack x, y - 1.. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Io | |
| tak := method(x, y, z, | |
| if(y < x, | |
| tak(tak(x - 1, y, z), tak(y - 1, z, x), tak(z - 1, x, y)) | |
| , | |
| z | |
| ) | |
| ) | |
| // Other |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - form_for :account, '/accounts', :id => 'loginform' do |f| | |
| dl class="zend_form" | |
| dt id="firstname-label" | |
| == f.label :name, :caption => "First name:" | |
| dd id="firstname-element" | |
| == f.text_field :name | |
| dt id="lastname-label" | |
| == f.label :surname, :caption => "Last name:" | |
| dd id="lastname-element" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /******************************************************************* | |
| * Caribou Programming Language | |
| * Copyright (C) 2010, Jeremy Tregunna, All Rights Reserved. | |
| * Originally written by: David Chisnall | |
| * | |
| * This software project, which includes this module, is protected | |
| * under Canadian copyright legislation, as well as international | |
| * treaty. It may be used only as directed by the copyright holder. | |
| * The copyright holder hereby consents to usage and distribution | |
| * based on the terms and conditions of the MIT license, which may |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function text-view (frame) | |
| ((NSTextView alloc) initWithFrame: frame)) | |
| (function text-field (frame) | |
| (((NSTextField alloc) initWithFrame: frame) | |
| set: (bezeled:0 editable:0 alignment:NSCenterTextAlignment drawsBackground:0))) | |
| (function alert-box (title message) | |
| (let (alert (NSAlert new)) | |
| (let (t (text-view '(0 0 300 100))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fib := n -> | |
| 0 to: 1 includes? n ifTrue: return n | |
| fib: n - 1. + fib: n - 2. | |
| fib := method: n, -> | |
| 0 to: 1 includes? n ifTrue: return n | |
| fib: n - 1. + fib: n - 2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Lexer := Object clone do( | |
| inputString := Sequence clone | |
| current ::= nil | |
| next ::= nil | |
| with := method(str, self clone setInputString(str)) | |
| setInputString := method(str, | |
| inputString = str | |
| self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Link: Object | |
| .next: nil | |
| .prev: nil | |
| .value: nil | |
| init: n | |
| .value: n | |
| at: idx | |
| .i: 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Complex := Sequence clone do( | |
| setItemType("float32") | |
| setSize(2) | |
| real := method(at(0)) | |
| imaginary := method(at(1)) | |
| setReal := method(a, atPut(0, a); self) | |
| setImaginary := method(a, atPut(1, a); self) | |
| with := method(r, i, self clone setReal(r) setImaginary(i)) | |
| abs := method((real * real + imaginary * imaginary) sqrt) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Converts any Io method (You'll have to wrap CFunctions in an Io method for those to work) to continuation passing style */ | |
| /* This is working code, not code someone posted asking for help. Feel free to use how you want, public domain. */ | |
| Object convertToCPS := method(str, | |
| m := self getSlot(str) | |
| blk := Block clone | |
| blk setArgumentNames(getSlot("m") argumentNames append("__k")) | |
| blk setMessage(Message clone fromString("__k call(self performWithArgList(\"#{str}\", call evalArgs append(__k)))" interpolate)) | |
| self setSlot("#{str}CPS" interpolate, blk setIsActivatable(true)) | |
| ) |