Enviar pesquisa
Carregar
Ruby haskell extension
•
Transferir como KEY, PDF
•
0 gostou
•
691 visualizações
Toshiyuki Terashita
Seguir
RubyからHaslekkで記述した関数を呼び出すサンプルの説明です。
Leia menos
Leia mais
Tecnologia
Educação
Denunciar
Compartilhar
Denunciar
Compartilhar
1 de 34
Baixar agora
Recomendados
20151224-games
20151224-games
Noritada Shimizu
2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js
Noritada Shimizu
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Cpp
Cpp
Ankit Dubey
Basic Programs of C++
Basic Programs of C++
Bharat Kalia
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
1
1
swetha gokavarapu
Include
Include
Shi Chakep
Recomendados
20151224-games
20151224-games
Noritada Shimizu
2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js
Noritada Shimizu
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Cpp
Cpp
Ankit Dubey
Basic Programs of C++
Basic Programs of C++
Bharat Kalia
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
1
1
swetha gokavarapu
Include
Include
Shi Chakep
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Include
Include
Angie Borda
C++ programs
C++ programs
Mukund Gandrakota
Bankers Algo Implementation
Bankers Algo Implementation
Deepak Agarwal
Oops in c++
Oops in c++
DravidSh
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
9096308941
Code
Code
Lay Chan Dara Raksmey
A Shiny Example-- R
A Shiny Example-- R
Dr. Volkan OBAN
Cpp tutorial
Cpp tutorial
Vikas Sharma
Oprerator overloading
Oprerator overloading
Parthipan Parthi
Modificacion del programa
Modificacion del programa
Mario José
PROGRAM FOR INSERTION SORTING IN ARRAY
PROGRAM FOR INSERTION SORTING IN ARRAY
daemian2
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
Dr. Loganathan R
ECMAScript 5: Новое в JavaScript
ECMAScript 5: Новое в JavaScript
Департамент Стратегических Технологий
Introduction to cron queue
Introduction to cron queue
ADCI Solutions
week-5x
week-5x
KITE www.kitecolleges.com
Document
Document
AjitRaj12
cosc 281 hw2
cosc 281 hw2
Brian Goggins
Frank-afcproxy
Frank-afcproxy
Toshiyuki Terashita
Amazon aws 20110611
Amazon aws 20110611
Toshiyuki Terashita
Mais conteúdo relacionado
Mais procurados
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Include
Include
Angie Borda
C++ programs
C++ programs
Mukund Gandrakota
Bankers Algo Implementation
Bankers Algo Implementation
Deepak Agarwal
Oops in c++
Oops in c++
DravidSh
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
9096308941
Code
Code
Lay Chan Dara Raksmey
A Shiny Example-- R
A Shiny Example-- R
Dr. Volkan OBAN
Cpp tutorial
Cpp tutorial
Vikas Sharma
Oprerator overloading
Oprerator overloading
Parthipan Parthi
Modificacion del programa
Modificacion del programa
Mario José
PROGRAM FOR INSERTION SORTING IN ARRAY
PROGRAM FOR INSERTION SORTING IN ARRAY
daemian2
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
Dr. Loganathan R
ECMAScript 5: Новое в JavaScript
ECMAScript 5: Новое в JavaScript
Департамент Стратегических Технологий
Introduction to cron queue
Introduction to cron queue
ADCI Solutions
week-5x
week-5x
KITE www.kitecolleges.com
Document
Document
AjitRaj12
cosc 281 hw2
cosc 281 hw2
Brian Goggins
Mais procurados
(20)
Pratik Bakane C++
Pratik Bakane C++
Pratik Bakane C++
Pratik Bakane C++
Pratik Bakane C++
Pratik Bakane C++
Include
Include
C++ programs
C++ programs
Bankers Algo Implementation
Bankers Algo Implementation
Oops in c++
Oops in c++
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
Code
Code
A Shiny Example-- R
A Shiny Example-- R
Cpp tutorial
Cpp tutorial
Oprerator overloading
Oprerator overloading
Modificacion del programa
Modificacion del programa
PROGRAM FOR INSERTION SORTING IN ARRAY
PROGRAM FOR INSERTION SORTING IN ARRAY
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
ECMAScript 5: Новое в JavaScript
ECMAScript 5: Новое в JavaScript
Introduction to cron queue
Introduction to cron queue
week-5x
week-5x
Document
Document
cosc 281 hw2
cosc 281 hw2
Destaque
Frank-afcproxy
Frank-afcproxy
Toshiyuki Terashita
Amazon aws 20110611
Amazon aws 20110611
Toshiyuki Terashita
Castoro sequense
Castoro sequense
Toshiyuki Terashita
Apache mod authまわりとか
Apache mod authまわりとか
Toshiyuki Terashita
Ruby2.0 - refinements - 鳥取Ruby会 第11回
Ruby2.0 - refinements - 鳥取Ruby会 第11回
Rie HIRONO
とっとるびー(2回目)発表資料
とっとるびー(2回目)発表資料
ionis111
Castoro / RubyKaigi2010
Castoro / RubyKaigi2010
Toshiyuki Terashita
Apache2.3 探訪
Apache2.3 探訪
KLab株式会社
Tottoruby 20130119
Tottoruby 20130119
Takashi SAKAGUCHI
Bazaar
Bazaar
KLab株式会社
Web Server - Internet Applications
Web Server - Internet Applications
sandra sukarieh
Destaque
(11)
Frank-afcproxy
Frank-afcproxy
Amazon aws 20110611
Amazon aws 20110611
Castoro sequense
Castoro sequense
Apache mod authまわりとか
Apache mod authまわりとか
Ruby2.0 - refinements - 鳥取Ruby会 第11回
Ruby2.0 - refinements - 鳥取Ruby会 第11回
とっとるびー(2回目)発表資料
とっとるびー(2回目)発表資料
Castoro / RubyKaigi2010
Castoro / RubyKaigi2010
Apache2.3 探訪
Apache2.3 探訪
Tottoruby 20130119
Tottoruby 20130119
Bazaar
Bazaar
Web Server - Internet Applications
Web Server - Internet Applications
Semelhante a Ruby haskell extension
C programs Set 2
C programs Set 2
Koshy Geoji
Bijender (1)
Bijender (1)
Ankush Kumar
C Programming lab
C Programming lab
Vikram Nandini
IR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdf
RahulRoy130127
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみた
Akira Maruoka
C Programming
C Programming
Sumant Diwakar
Basicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt application
Dinesh Manajipet
C basics
C basics
MSc CST
'C' language notes (a.p)
'C' language notes (a.p)
Ashishchinu
CppTutorial.ppt
CppTutorial.ppt
HODZoology3
Final DAA_prints.pdf
Final DAA_prints.pdf
Yashpatel821746
7720
7720
Yashpatel821746
All I know about rsc.io/c2go
All I know about rsc.io/c2go
Moriyoshi Koizumi
JVM code reading -- C2
JVM code reading -- C2
ytoshima
C++ manual Report Full
C++ manual Report Full
Thesis Scientist Private Limited
ISCA Final Presentaiton - Compilations
ISCA Final Presentaiton - Compilations
HSA Foundation
R (Shiny Package) - Server Side Code for Decision Support System
R (Shiny Package) - Server Side Code for Decision Support System
Maithreya Chakravarthula
Billing in a supermarket c++
Billing in a supermarket c++
varun arora
C lab programs
C lab programs
Dr. Prashant Vats
C lab programs
C lab programs
Dr. Prashant Vats
Semelhante a Ruby haskell extension
(20)
C programs Set 2
C programs Set 2
Bijender (1)
Bijender (1)
C Programming lab
C Programming lab
IR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdf
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみた
C Programming
C Programming
Basicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt application
C basics
C basics
'C' language notes (a.p)
'C' language notes (a.p)
CppTutorial.ppt
CppTutorial.ppt
Final DAA_prints.pdf
Final DAA_prints.pdf
7720
7720
All I know about rsc.io/c2go
All I know about rsc.io/c2go
JVM code reading -- C2
JVM code reading -- C2
C++ manual Report Full
C++ manual Report Full
ISCA Final Presentaiton - Compilations
ISCA Final Presentaiton - Compilations
R (Shiny Package) - Server Side Code for Decision Support System
R (Shiny Package) - Server Side Code for Decision Support System
Billing in a supermarket c++
Billing in a supermarket c++
C lab programs
C lab programs
C lab programs
C lab programs
Último
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
Gabriella Davis
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
The Digital Insurer
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
UK Journal
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
Radu Cotescu
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
Khem
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
Delhi Call girls
🐬 The future of MySQL is Postgres 🐘
🐬 The future of MySQL is Postgres 🐘
RTylerCroy
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
HampshireHUG
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
debabhi2
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
ThousandEyes
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Drew Madelung
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
Malak Abu Hammad
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Principled Technologies
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Enterprise Knowledge
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
The Digital Insurer
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
Delhi Call girls
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Miguel Araújo
Último
(20)
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
🐬 The future of MySQL is Postgres 🐘
🐬 The future of MySQL is Postgres 🐘
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Ruby haskell extension
1.
2.
3.
4.
5.
6.
7.
�
8.
9.
foreign import ccall
”math.h sin” sin :: CDouble -> CDouble foreign export ccall ”fact” fact :: CInt -> CInt
10.
�
11.
== factorial.hs == Module
Factorial where import Foreign.C.Types foreign export ccall ”factorial” factorial :: CInt -> Cint factorial 0 = 1 factorial x = x * factorial(x-1)
12.
13.
== main.c == #include
<stdio.h> #include “factorial_stub.h” int main(int argc, char* argv[]) { hs_init(&argc, &argv); printf(“%dn”, fact(5)); hs_exit(); return 0; }
14.
$ ghc -shared
-dynamic ... ( )
15.
#include <ruby.h> #include "factorial_stub.h" static
VALUE rb_factorial(VALUE self, VALUE val) { return UINT2NUM(factorial(NUM2UINT(val))); } void Init_factorial(void) { hs_init(NULL, NULL);// Haskell .. rb_define_module_function(rb_mMath, "factorial", RUBY_METHOD_FUNC(rb_factorial), 1); }
16.
(gem install
) $ irb -r factorial/factorial irb(main):001:0> Math.factorial 4 => 24
17.
foreign export ccall
”factorial” factorial :: CInt -> CInt CInt -229 +229-1 9 362,880 10 3,628,800 15 1.30767E+12
18.
19.
20.
21.
$ cd `ghc
--print-libdir` �
22.
23.
24.
require 'rbconfig' TARGET =
'factorial' C_SRC = %w{ main.c } HS_SRC = %w{ factorial.hs } HS_LIBS = %w{ base integer-gmp ghc-prim } CONF = RbConfig::MAKEFILE_CONFIG VALS = %w{prefix includedir RUBY_BASE_NAME ruby_version rubyhdrdir arch MKDIR_P INSTALL INSTALL_PROGRAM}.map{|k| "#{k}=#{CONF[k]}" }.join("n") GHC_LIBDIR=`ghc --print-libdir`.strip FLAGS = "FLAGS=-I$(rubyhdrdir) -I$(rubyhdrdir)/$(arch) - shared -dynamic -no-hs-main -lHSrts -lffin" + "FLAGS+=-no-auto-link-packages -I#{GHC_LIBDIR}/ include -L#{GHC_LIBDIR}n" + HS_LIBS.map{|l| 'FLAGS+=' + `ghc-pkg describe #{l}|sed -ne 's/ library-dirs: /-L/p;s/hs-libraries: /-l/p;'`.gsub(/n/, ' ') }.join("n") + "nFLAGS+=-lgmpn"
25.
File.open("Makefile", "w") {|f|
f.puts <<__MAKEFILE__ TARGET=#{TARGET}.#{CONF['DLEXT']} HS_SRC=#{HS_SRC.join(' ')} C_SRC=#{C_SRC.join(' ')} #{VALS} #{FLAGS} STUB=$(HS_SRC:.hs=_stub.o) all : $(TARGET) $(STUB) : $(HS_SRC) ghc $< $(TARGET) : $(C_SRC) $(STUB) $(HS_SRC:.hs=.o) ghc -o $@ $^ $(FLAGS) install: $(MKDIR_P) ../lib/#{TARGET}/ $(INSTALL_PROGRAM) $(TARGET) ../lib/#{TARGET}/ clean: rm -f $(TARGET) $(C_SRC:.c=.o) $(HS_SRC:.hs=.hi) $ (HS_SRC:.hs=.o) $(HS_SRC:.hs=_stub.)* __MAKEFILE__ }
26.
27.
28.
29.
� �
30.
�
Notas do Editor
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Baixar agora